Skip to content
Browse files

Remove extant pid files with a warning.

Restarting workers on boot after a sudden shutdown was problematic.
  • Loading branch information...
1 parent 823fb2e commit 55bed326a6f677e8a6ae2a855968288fb1668658 @guns committed Feb 10, 2012
Showing with 7 additions and 9 deletions.
  1. +7 −9 lib/delayed/daemon_tasks.rb
View
16 lib/delayed/daemon_tasks.rb
@@ -66,20 +66,18 @@
end
end
- # create pidfile or abort
+ # Create / overwrite pidfile
pid_dir = "#{rails_root}/tmp/pids"
pid_file = "#{pid_dir}/#{$0}.pid"
if File.exists? pid_file
- msg = "PID file #{pid_file} already exists!"
- logger.call msg
- abort msg
- else
- # silence output like a proper daemon
- [$stdin, $stdout, $stderr].each { |io| io.reopen '/dev/null' }
- mkdir_p pid_dir, :verbose => false
- File.open(pid_file, 'w') { |f| f.write $$ }
+ logger.call "WARNING: PID file #{pid_file} already exists!"
end
+ # silence output like a proper daemon
+ [$stdin, $stdout, $stderr].each { |io| io.reopen '/dev/null' }
+ mkdir_p pid_dir, :verbose => false
+ File.open(pid_file, 'w') { |f| f.write $$ }
+
# spawn the first workers
children, times_dead = {}, {}
worker_count = (ENV['WORKERS'] || 1).to_i

0 comments on commit 55bed32

Please sign in to comment.
Something went wrong with that request. Please try again.