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_ma开发者_开发技巧iler
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)
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"
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.
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
精彩评论