Skip to content

Commit

Permalink
Daemons should die when receiving a TERM signal.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Van Dyk authored and quirkey committed May 9, 2011
1 parent 5211c46 commit 6dffd5f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/vegas/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,13 @@ def run!
logger.info "Running with Rack handler: #{@rack_handler.inspect}"

rack_handler.run app, :Host => host, :Port => port do |server|
trap(kill_command) do
## Use thins' hard #stop! if available, otherwise just #stop
server.respond_to?(:stop!) ? server.stop! : server.stop
logger.info "#{quoted_app_name} received INT ... stopping"
delete_pid!
kill_commands.each do |command|
trap(command) do
## Use thins' hard #stop! if available, otherwise just #stop
server.respond_to?(:stop!) ? server.stop! : server.stop
logger.info "#{quoted_app_name} received INT ... stopping"
delete_pid!
end
end
end
end
Expand Down Expand Up @@ -378,8 +380,8 @@ def define_options
exit
end

def kill_command
WINDOWS ? 1 : :INT
def kill_commands
WINDOWS ? [1] : [:INT, :TERM]
end

def delete_pid!
Expand Down

0 comments on commit 6dffd5f

Please sign in to comment.