module Soaring class Runner def initialize(options) @options = options end def run if @options[:autorestart] run_repeatedly else run_once end end private def run_repeatedly while true do $stderr.puts "starting rackup repeatedly with parameters #{compile_rackup_parameters}" if @options[:verbose] response, exit_status = Executor::execute("cd #{@options[:project_root]}; bundle exec rackup #{compile_rackup_parameters}") sleep(0.5) end end def run_once $stderr.puts "starting rackup once with parameters #{compile_rackup_parameters}" if @options[:verbose] exec("cd #{@options[:project_root]}; bundle exec rackup #{compile_rackup_parameters}") end def compile_rackup_parameters bind_address = '0.0.0.0' rackup_parameters = "-E #{@options[:environment]} ./config.ru -p #{@options[:port]} --host #{bind_address}" end end end