Question

I realize this title is a mouthful...

My app is currently setup to send out emails to all users each day when there has been activity on the account. To achieve this, I run a cron task through rufus_scheduler, and delay the email delivery using delayed_job which looks something like this:

scheduler.cron("0 12 * * *") do
  User.all.each do |user|
    Newideas.delay.newideas_email(user)
  end
end

Unfortunately, it seems that using this combination (rufus_scheduler & delayed_job) is causing the emails to be delivered twice to each user when deployed on Heroku.

I've tried to replicate this in development, but I've been unable to. Also, the problem doesn't occur when I trigger a delayed_job using a controller method - i.e. when someone creates a new account, etc.

Any help in sorting this out would be greatly appreciated.

Thanks very much.

Was it helpful?

Solution

Why not just use the Heroku scheduler and call it via that? It spawns a seperate process so then there's no need to use delayed_job in there as well...simplify :)

OTHER TIPS

Maybe the reason for this is simply, that you call scheduler.cron in a config/initializer/what_ever file and so the scheduler is running in the rails process AND and in the delayed_job process?

This may be a simple answer to that question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top