如何在生产环境中运行delayed_jobs

时间:2015-01-30 11:26:53

标签: ruby-on-rails ruby ruby-on-rails-4 delayed-job

我在rails应用程序开发中使用delayed_job,在开发环境中我使用bin/delayed_job start

但是如何在生产环境中做同样的事情?

3 个答案:

答案 0 :(得分:2)

RAILS_ENV=production bin/delayed_job start

这应该使延迟的作业在生产环境中运行

答案 1 :(得分:1)

开始:

cd /home/user/app;
bundle exec /usr/bin/env RAILS_ENV=production /home/user/app/script/delayed_job start

停止:

cd /home/user/app; 
bundle exec /usr/bin/env RAILS_ENV=production /home/user/app/script/delayed_job stop

请参阅github的官方文档。

RAILS_ENV=production script/delayed_job start
RAILS_ENV=production script/delayed_job stop

# Runs two workers in separate processes.
RAILS_ENV=production script/delayed_job -n 2 start
RAILS_ENV=production script/delayed_job stop

# Set the --queue or --queues option to work from a particular queue.
RAILS_ENV=production script/delayed_job --queue=tracking start
RAILS_ENV=production script/delayed_job --queues=mailers,tasks start

# Use the --pool option to specify a worker pool. You can use this option multiple times to start different numbers of workers for different queues.
# The following command will start 1 worker for the tracking queue,
# 2 workers for the mailers and tasks queues, and 2 workers for any jobs:
RAILS_ENV=production script/delayed_job --pool=tracking --pool=mailers,tasks:2 --pool=*:2 start

# Runs all available jobs and then exits
RAILS_ENV=production script/delayed_job start --exit-on-complete
# or to run in the foreground
RAILS_ENV=production script/delayed_job run --exit-on-complete

答案 2 :(得分:0)

万一其他人陷入-bash:bin / delayed_job:权限被拒绝的错误(如Disha在上面的注释中所做的那样),对于Centos来说,只需将项目目录中bin /文件夹中的delay_job设置为可执行文件即可。