class Soaring::Runner

Public Class Methods

new(options) click to toggle source
# File lib/soaring/runner.rb, line 3
def initialize(options)
  @options = options
end

Public Instance Methods

run() click to toggle source
# File lib/soaring/runner.rb, line 7
def run
  Dir.chdir(@options[:project_root]) do
    if @options[:autorestart]
      run_repeatedly
    else
      run_once
    end
  end
end

Private Instance Methods

compile_rackup_parameters() click to toggle source
# File lib/soaring/runner.rb, line 32
def compile_rackup_parameters
  bind_address = '0.0.0.0'
  rackup_parameters = "-E #{@options[:environment]} ./config.ru -p #{@options[:port]} --host #{bind_address}"
end
run_once() click to toggle source
# File lib/soaring/runner.rb, line 27
def run_once
  $stderr.puts "starting rackup once with parameters #{compile_rackup_parameters}" if @options[:verbose]
  exec("bundle exec rackup #{compile_rackup_parameters}")
end
run_repeatedly() click to toggle source
# File lib/soaring/runner.rb, line 19
def run_repeatedly
  while true do
    $stderr.puts "starting rackup repeatedly with parameters #{compile_rackup_parameters}" if @options[:verbose]
    response, exit_status = Executor::execute("bundle exec rackup #{compile_rackup_parameters}")
    sleep(0.5)
  end
end