Hi Georg,
sorry for the late reply, I'm currently travelling.
Have you tried to use a lock file ?
---8<---
require 'FileUtils'
if RAILS_ENV == 'production' && (not File.exist?('tmp/my_scheduler.lock'))
FileUtils.touch('tmp/my_scheduler.lock')
scheduler = ...
end
--->8---
Note that it would then be necessary to remove that lock file when
Mongrel shuts down :
---8<---
if Module.constants.include?('Mongrel') then
class Mongrel::HttpServer
alias :old_graceful_shutdown :graceful_shutdown
def graceful_shutdown
FileUtils.rm('tmp/my_scheduler.lock', :force => true)
old_graceful_shutdown
end
end
end
--->8---
I hope this will help, best regards,
--
John Mettraux - http://jmettraux.wordpress.com
Hi Tim,
I guess it's possible to do the same with passenger.
Creating the lock file would be the same.
For the shutdown part, you'd have to locate/identify the shutdown
hook/method for passenger.
Maybe this simple piece of code could work instead :
---8<---
at_exit do
FileUtils.rm('tmp/my_scheduler.lock', :force => true)
end
--->8---
(There were sometimes problem with it and Mongrel, hence the specific
Mongrel shutdown hook).