Skip to content

Commit

Permalink
KISS and check to see if the file exists before checking its mtime
Browse files Browse the repository at this point in the history
Fixes bug where the master would constantly raise SIGHUP when
'restart.txt' didn't exist
  • Loading branch information
guns committed Sep 17, 2010
1 parent 4b52cbc commit 9b8bf90
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/delayed/daemon_tasks.rb
Expand Up @@ -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
Expand Down

0 comments on commit 9b8bf90

Please sign in to comment.