Skip to content

Commit

Permalink
Trap the exit instead of specific signals, and preserve a possibly ex…
Browse files Browse the repository at this point in the history
…isting handler
  • Loading branch information
vjt committed Apr 12, 2011
1 parent ad1ff73 commit 6425a5a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/mimic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ module Mimic
:hostname => 'localhost',
:port => MIMIC_DEFAULT_PORT,
:remote_configuration_path => nil,
:fork => true,
:trap_signals => true
:fork => true
}

def self.mimic(options = {}, &block)
Expand Down Expand Up @@ -67,9 +66,9 @@ def start_service(app, options)
}) do |server|
@server = server

if options[:trap_signals]
trap("TERM") { @server.shutdown }
trap("INT") { @server.shutdown }
old = trap('EXIT') do
old.call if old
@server.shutdown
end
end
end
Expand Down

0 comments on commit 6425a5a

Please sign in to comment.