Module: Boxlet
- Included in:
- Boxlet
- Defined in:
- lib/boxlet.rb,
lib/boxlet/db.rb,
lib/boxlet/app.rb,
lib/boxlet/log.rb,
lib/boxlet/util.rb,
lib/boxlet/config.rb,
lib/boxlet/runner.rb,
lib/handlers/auth.rb,
lib/handlers/thin.rb,
lib/boxlet/version.rb,
lib/boxlet/app/models.rb,
lib/boxlet/app/router.rb,
lib/boxlet/app/templates.rb,
lib/boxlet/app/controller.rb
Defined Under Namespace
Modules: Config, Db, Handlers, Models, Util Classes: App, Controller, Log, Router, Runner, Templates
Constant Summary collapse
- PUBLIC_COMMANDS =
{ run: "Run the Boxlet server", stop: "Stop a daemonized server" }.freeze
- VERSION =
"1.0.5"
Constants included from Config
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#raw_config ⇒ Object
Returns the value of attribute raw_config.
-
#raw_params ⇒ Object
Returns the value of attribute raw_params.
-
#runner ⇒ Object
Returns the value of attribute runner.
Instance Method Summary collapse
- #debug? ⇒ Boolean
- #log(level, message) ⇒ Object
- #params ⇒ Object
- #run!(argv, command = 'run', config_file = 'config.yml', &blk) ⇒ Object
- #stop! ⇒ Object
Methods included from Config
populate_params!, symbolize_keys
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
20 21 22 |
# File 'lib/boxlet.rb', line 20 def config @config end |
#raw_config ⇒ Object
Returns the value of attribute raw_config.
20 21 22 |
# File 'lib/boxlet.rb', line 20 def raw_config @raw_config end |
#raw_params ⇒ Object
Returns the value of attribute raw_params.
20 21 22 |
# File 'lib/boxlet.rb', line 20 def raw_params @raw_params end |
#runner ⇒ Object
Returns the value of attribute runner.
20 21 22 |
# File 'lib/boxlet.rb', line 20 def runner @runner end |
Instance Method Details
#debug? ⇒ Boolean
55 56 57 |
# File 'lib/boxlet.rb', line 55 def debug? @config[:debug] == true end |
#log(level, message) ⇒ Object
67 68 69 |
# File 'lib/boxlet.rb', line 67 def log(level, ) @log.write(level, ) end |
#params ⇒ Object
63 64 65 |
# File 'lib/boxlet.rb', line 63 def params @params end |
#run!(argv, command = 'run', config_file = 'config.yml', &blk) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/boxlet.rb', line 22 def run!(argv, command='run', config_file='config.yml', &blk) populate_params!(argv, config_file) @log = Boxlet::Log.new(@config[:log_file], (debug? ? Logger::DEBUG : Logger::INFO)) @app = Boxlet::App.new command = command.to_s.to_sym case command when :run Boxlet.log(:debug, @config) @runner = Boxlet::Runner.new @runner.start(@app.bind, &blk) when :stop if @config[:daemonize] == true pid = File.read(@config[:pid_file]).to_i puts "Killing #{pid}..." Process.kill(Signal.list["TERM"], pid) end else if App::PUBLIC_COMMANDS.keys.include?(command) @app.send(command, argv) else end end @app end |
#stop! ⇒ Object
50 51 52 53 |
# File 'lib/boxlet.rb', line 50 def stop! @runner.stop @app end |