Class: Halcyon::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/halcyon/runner.rb,
lib/halcyon/runner/helpers.rb,
lib/halcyon/runner/commands.rb,
lib/halcyon/runner/helpers/command_helper.rb

Overview

Handles initializing and running the application, including:

  • setting up the logger

  • loading initializers

  • loading controllers

All of which is done by the call to Halcyon::Application.boot.

The Runner is a full-fledged Rack application, and accepts calls to #call.

Also handles running commands form the command line.

Examples

# start serving the current app (in .)
Halcyon::Runner.run!(['start', '-p', '4647'])

# load the config file and initialize the app
Halcyon::Runner.new

Defined Under Namespace

Classes: Commands, Helpers

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Runner

Initializes the application and application resources.



26
27
28
29
# File 'lib/halcyon/runner.rb', line 26

def initialize(&block)
  Halcyon::Application.boot(&block) unless Halcyon::Application.booted
  @app = Halcyon::Application.new
end

Class Method Details

.run!(argv = ARGV) ⇒ Object

Runs commands from the CLI.

+argv+ the arguments to pass to the commands

Returns nothing



47
48
49
# File 'lib/halcyon/runner.rb', line 47

def run!(argv=ARGV)
  Commands.send(argv.shift, argv)
end

Instance Method Details

#call(env) ⇒ Object

Calls the application, which gets proxied to the dispatcher.

+env+ the request environment details

Returns [Fixnum:status, => String:value, [String:body]]



36
37
38
# File 'lib/halcyon/runner.rb', line 36

def call(env)
  @app.call(env)
end