Question

I am currently using a site5 server and would like rake jobs:work pretty much running all the time. I currently cannot send out the jobs unless i'm logged into the server. I hope that someone out there can help me with this. Had alot of trouble with ar_mailer and the whenever gem ... but have about another 5 gems working perfectly within my rails app.

can someone shed some light on a solution for this please? greatly appreciated. (installed delayed_job as a plugin)

Was it helpful?

Solution 2

OK I have a workaround for this, it's the best I can do but it works to some degree ... I made use of CRON jobs and a custom script/jobrunner file.

I created the jobrunner script located at script/jobrunner which contains the following

#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/environment'
Delayed::Worker.new.start

Then in a cron job i made it run that file.

In the cron report i still get a few errors, but the jobs run and i'm happy with that!

The cron job is running every hour on the 50th minute for example, and it goes through all the delayed_jobs in the table and processes them. This is the next best workaround solution that i have found to my problem. hope this helps someone out in the future.

Going to see what other scripts i can conjure up for daily/weekly tasks.

OTHER TIPS

If you are using capistrano, start delayed_job when your app is deployed. Add this to your deploy recipe file.

require 'delayed/recipes'
after "deploy:stop",        "delayed_job:stop"
after "deploy:start",       "delayed_job:start"
after "deploy:update_code", "delayed_job:stop"
after "deploy:restart",     "delayed_job:start"

Delayed job comes with a script for starting itself in the background and logging to log/delayed_job.log. You can start a daemonized delayed_job running in development mode like this:

RAILS_ENV=development script/delayed_job start
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top