Search code examples
ruby-on-railsredispassengerresqueresque-scheduler

Dynamic Schedules getting lost while resque forks a new process


I'm using resque-scheduler to schedule dynamic crons based on user's input. My server stack is using Ubuntu 12.04 with passenger + nginx configuration.

I've set Resque::Scheduler.dynamic = true and using set_schedule method with persist: true option to schedule dynamic jobs

At first the problem was it was giving me some Passenger error:-

Redis::InheritedError (Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking.

So i introduced the following block to my resque initializer:-

PhusionPassenger.on_event(:starting_worker_process) do |forked|
  if forked
    # Reconnect Resque Redis instance.
    Resque.redis.client.reconnect
  end
end

Now after each restart or scheduling a new dynamic job, it loads my static schedules and dynamic schedules are being lost. Even it is updating schedules o random time and loads only static schedules.


Solution

  • The problem of loading dynamic schedules is there in the gem version. Please refer to latest resque scheduler release at github, this should fix the issue(fixed about 10 days back).