restartfile = Rails.root.join('tmp', 'restart.txt')
touchtime = Time.now
Rails.logger.info("reload_config: mtime on #{conffile} changed to #{t}, touching #{restartfile} to #{touchtime}")
- File.utime(touchtime, touchtime, restartfile)
+ begin
+ File.utime(touchtime, touchtime, restartfile)
+ rescue
+ # remove + re-create works even if the existing file is
+ # owned by root, provided the tempdir is writable.
+ File.unlink(restartfile) rescue nil
+ File.open(restartfile, 'w') {}
+ end
# Even if passenger doesn't notice that we hit restart.txt
# and kill our process, there's no point waiting around to
# hit it again.