diff options
Diffstat (limited to 'lib/nickserver')
-rw-r--r-- | lib/nickserver/daemon.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/nickserver/daemon.rb b/lib/nickserver/daemon.rb index c6752d8..9a50e36 100644 --- a/lib/nickserver/daemon.rb +++ b/lib/nickserver/daemon.rb @@ -113,11 +113,7 @@ module Nickserver else bail "Error reading pid file #{file}" end - begin - FileUtils.rm Config.pid_file - rescue Errno::EACCES - bail 'insufficient permission to remove pid file' - end + remove_pid_file else bail "could not find pid file #{file}" end @@ -125,18 +121,20 @@ module Nickserver puts "Failed to stop: #{e}" end + def remove_pid_file + FileUtils.rm Config.pid_file + rescue Errno::EACCES + bail 'insufficient permission to remove pid file' + end + # # stop when we should # def catch_signals - sigtrap = proc { - command_stop - $stdout.puts "\nQuit" - $stdout.flush - exit - } ["SIGTERM", "SIGINT", "SIGHUP"].each do |signal| - Signal.trap(signal, sigtrap) + Signal.trap(signal) { + exit + } end end |