run multi delayed_job instances per RAILS_ENV

Deadly 提交于 2019-12-04 06:09:41

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 script/delayed_job -i 1 start

RAILS_ENV=env_name2 script/delayed_job -i 2 start

This would create two seperate delayed job instances, naming them delayed_job.1 and delayed_job.2

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.

Not sure if it'll solve your problem but... I often need to run multiple versions of script/server - and those don't play nice with each other either. The way to get them running is to use different ports. eg:

RAILS_ENV=env_name1 script/server -p 3000
RAILS_ENV=env_name2 script/server -p 3002

Perhaps this'll work for delayed_job too?

(though I'd avoid port 3000 as it's the std rails port) :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!