开发者

Delayed Jobs on Rails 2: any better way to run workers?

开发者 https://www.devze.com 2023-01-31 04:01 出处:网络
I finally got the DelayedJobs plugin working for Rails 2, and it does indeed work fine...as long as I run:

I finally got the DelayedJobs plugin working for Rails 2, and it does indeed work fine...as long as I run:

rake jobs:work

Just like the readme says, to be fair.

BUT, this doesn't fit my requirements...what kind of background task requires you to have a shell open, and a command running? That'd be like having to say script/server to run my rails app, and never getting that -d option so it'll keep running even after I close my shell.

Is there ANY way to keep the workers getting processed in the backgroun, or in daemon mode, or whatever?

I had a ray of hope when I saw the

You can also run by writing a simple @script/job_runner@, and invoking it externally:

Line in the readme...but...that just does the exac开发者_StackOverflowt same thing the rake task does, you just call it a different way.

What I want:

I want to start my rails app, then start whatever will process the workers, and have BOTH of them run invisibly in the background, without the need for me to babysit it and keep the shell that started it running.

(My server is something I SSH into, so I don't want to have that shell that SSHed into it running 24/7 (especially since I like to turn off my local computer now and again)).

Is there any way to acomplish this?


You can make any *nix command run on the background by appending an & to its end:

rake jobs:work &

Just make sure you exit the shell (or use the disown command) to detach the process from your login session... Otherwise, if your session disconnects, the processes you own will be killed with it.


Perhaps Beanstalkd and Stalker?

Beanstalk is a fast and easy way to queue background tasks. Stalker provides a nice wrapper interface for creating these jobs.

See the railscast on it for more information

Edit:

You could also run that rake task as a cronjob which would mean the server would run it periodically without you needing to be logged in


Use the collectiveidea fork of delayed_job... It's more actively developed and has support for running the jobs in a daemon without any extra messing about.


My capistrano script calls

RAILS_ENV=production script/delayed_job start
0

精彩评论

暂无评论...
验证码 换一张
取 消