lib/soaring/runner.rb in soaring-0.1.12 vs lib/soaring/runner.rb in soaring-0.1.13
- old
+ new
@@ -3,13 +3,34 @@
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}"
- puts "starting rackup with parameters #{rackup_parameters}" if @options[:verbose]
- exec("bundle exec rackup #{rackup_parameters}")
end
end
end