summaryrefslogtreecommitdiff
path: root/lib/nickserver/daemon.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nickserver/daemon.rb')
-rw-r--r--lib/nickserver/daemon.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/nickserver/daemon.rb b/lib/nickserver/daemon.rb
index d03c394..c6752d8 100644
--- a/lib/nickserver/daemon.rb
+++ b/lib/nickserver/daemon.rb
@@ -65,7 +65,7 @@ module Nickserver
Process.setsid
exit if fork
create_pid_file(Config.pid_file, Config.user)
- catch_interrupt
+ catch_signals
redirect_output
drop_permissions_to(Config.user) if Config.user
File.umask 0000
@@ -126,18 +126,20 @@ module Nickserver
end
#
- # Gracefully handle Ctrl-C
+ # stop when we should
#
- def catch_interrupt
- Signal.trap("SIGINT") do
+ def catch_signals
+ sigtrap = proc {
command_stop
$stdout.puts "\nQuit"
$stdout.flush
exit
+ }
+ ["SIGTERM", "SIGINT", "SIGHUP"].each do |signal|
+ Signal.trap(signal, sigtrap)
end
end
-
#
# OUTPUT
#