每运行RAILS_ENV多delayed_job的情况下, [英] run multi delayed_job instances per RAILS_ENV
问题描述
我的工作多RAILS_ENV
I'm working on a Rails app with multi RAILS_Env
env_name1:
adapter: mysql
username: root
password:
host: localhost
database: db_name_1
env_name2:
adapter: mysql
username: root
password:
host: localhost
database: db_name_2
...
..
.
和我使用的delayed_job(2.0.5)的插件管理asynchrone和背景的工作。
And i'm using delayed_job (2.0.5) plugin to manage asynchrone and background work.
我想每次启动RAILS_ENV多delayed_job的:
I would like start multi delayed_job per RAILS_ENV:
RAILS_ENV=env_name1 script/delayed_job start
RAILS_ENV=env_name2 script/delayed_job start
..
我注意到,我只能运行一个实例的delayed_job
对于第二个,我有这样的错误错误:已经有运行该程序的一个或多个实例(S)
I noticed that I can run only one delayed_job instance for the 2nd, I have this error "ERROR: there is already one or more instance(s) of the program running"
我的问题:岂不等于可以运行每RAILS_ENV多delayed_job的实例?
谢谢
My question : is't possible to run multi delayed_job instances per RAILS_ENV? Thanks
推荐答案
您可以有,只要它们有不同的进程名工作延迟运行多个实例。斯利姆一样在他的评论中提到,您可以使用-i标志为一个唯一的数字标识符添加到该进程名。于是命令将如下所示:
You can have multiple instance of delayed job running as long as they have different process names. Like Slim mentioned in his comment, you can use the -i flag to add a unique numerical identifier to the process name. So the commands would look like:
RAILS_ENV = env_name1脚本/ delayed_job的-i 1日开始
RAILS_ENV=env_name1 script/delayed_job -i 1 start
RAILS_ENV = env_name2脚本/ delayed_job的-i 2启动
RAILS_ENV=env_name2 script/delayed_job -i 2 start
这将创建两个单独的延迟作业实例,命名它们delayed_job.1和delayed_job.2
This would create two seperate delayed job instances, naming them delayed_job.1 and delayed_job.2
一个小问题,就是当你这样做,你也可以阻止他们时使用的相同的标志。省略-i 1或2 -i打电话时停,也不会阻止他们。作为延迟作业将不能找到正确的相应的过程停下来。
A gotcha is that when you do this you also have to use the same flags when stopping them. Omitting the -i 1 or -i 2 when calling stop, won't stop them. As delayed job won't be able to find the correct corresponding process to stop.
这篇关于每运行RAILS_ENV多delayed_job的情况下,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!