简体   繁体   中英

In heroku how do you get ruby/rails to start a worker

I'm running ruby/rails on heroku, and I want to scale my workers..

Heroku has this great api to scale the workers..

heroku.post_ps_scale(APP_NAME, 'worker', count) 
#brings up new worker dyno's, or scales down

The problem is the workers are not aware of queues... If I have two clients and each get their own queues in delayed job. Then their tasks clash with each other.

To get workers working on different queues, but they are on the same dyno as the app that started them (aka the web dyno)

cmd = "rake jobs:work WORKER=STYLE_SERF QUEUES=#{queue}"
Rush::Box.new[Rails.root].bash( cmd, :background => true )

Question How do I create worker dyno's that are queue aware?
I expect it would be some combination of the code above.

EDIT: Some have suggested that I make use of the procFile, the problem I face is that I don't know the number or worker queues that I'm going to need. It is excellent for setting up "urgent" or "due_yesterday" workers who work off specific queues... but I want to have a queue per client.
So worker_1 works on client_1 jobs and worker_2 works on client_2 jobs. Never crossing to the other.
It's easy to imagine client_1 doing product updates every hour and client_2 doing them once a week.

EXTENDED QUESTION (based on edit) Can one adjust the procfile at run time? Is it a file, or is it compiled into the code? If it's an accessible file, then perhaps I could "create" worker types.

您可以尝试http://hirefire.io/,它的价格是每月10美元,您有30天的时间可以尝试使用,但是根据您的队列大小和响应时间,可以极大地扩展worker和dynos的大小,并且它是可自定义的!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM