lib/vegas/runner.rb in vegas-0.1.6 vs lib/vegas/runner.rb in vegas-0.1.7

- old
+ new

@@ -41,10 +41,15 @@ opts.separator '' opts.separator "#{quoted_app_name} options:" yield(self, opts, app) end end + + if @should_kill + kill! + exit!(0) + end # Handle :before_run hook if (before_run = options.delete(:before_run)).respond_to?(:call) before_run.call(self) end @@ -148,11 +153,11 @@ if File.exists?(pid_file) && File.exists?(url_file) running_url = File.read(url_file) if !port_open?(running_url) logger.warn "#{quoted_app_name} is already running at #{running_url}" launch!(running_url, path) - exit! + exit!(1) end end end def run! @@ -170,11 +175,11 @@ # Adapted from Rackup def daemonize! if RUBY_VERSION < "1.9" logger.debug "Parent Process: #{Process.pid}" - exit! if fork + exit!(0) if fork logger.debug "Child Process: #{Process.pid}" else Process.daemon(true, true) end @@ -282,16 +287,15 @@ opts.separator "" opts.separator "Vegas options:" opts.on('-K', "--kill", "kill the running process and exit") {|k| - kill! - exit + @should_kill = true } opts.on('-S', "--status", "display the current running PID and URL then quit") {|s| status - exit! + exit!(0) } opts.on("-s", "--server SERVER", "serve using SERVER (thin/mongrel/webrick)") { |s| @rack_handler = Rack::Handler.get(s) }