Permalink
Browse files

KISS and check to see if the file exists before checking its mtime

Fixes bug where the master would constantly raise SIGHUP when
'restart.txt' didn't exist
  • Loading branch information...
1 parent 4b52cbc commit 9b8bf90a3e9e05d50dc3666506a1912ab53b1acd guns committed Sep 17, 2010
Showing with 6 additions and 8 deletions.
  1. +6 −8 lib/delayed/daemon_tasks.rb
@@ -136,16 +136,14 @@
# reap dead children before the SIGCLD handler does
#
# poll passenger restart file and restart on update
- years_ago = lambda { |n| Time.now - 60 * 60 * 24 * 365 * n }
- mtime = lambda do |file|
- File.exists?(file) ? File.mtime(file) : years_ago.call(2)
- end
restart_file = "#{rails_root}/tmp/restart.txt"
- last_modified = mtime.call restart_file
+ last_modified = File.mtime restart_file if File.exists? restart_file
loop do
- if (check = mtime.call restart_file) > last_modified
- last_modified = check
- Process.kill :HUP, $$
+ if File.exists? restart_file
+ if (check = File.mtime restart_file) > last_modified
+ last_modified = check
+ Process.kill :HUP, $$
+ end
end
sleep 5
end

0 comments on commit 9b8bf90

Please sign in to comment.