简体   繁体   English

在heroku中,如何获得红宝石/铁轨来开始工作

[英]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上运行ruby / rails,我想扩展我的工人。

Heroku has this great api to scale the workers.. Heroku拥有强大的api来扩展工作人员。

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? 问题 我如何创建知道队列的工人dyno?
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. 编辑:有人建议我使用procFile,我面临的问题是我不知道我将需要的数量或工作人员队列。 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. 设置“紧急”或“ due_yesterday”工作人员以解决特定的队列非常好...但是我希望每个客户都有一个队列。
So worker_1 works on client_1 jobs and worker_2 works on client_2 jobs. 因此,worker_1在client_1上工作,而worker_2在client_2上工作。 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. 不难想象client_1每小时进行一次产品更新,client_2每周进行一次产品更新。

EXTENDED QUESTION (based on edit) Can one adjust the procfile at run time? 扩展问题(基于编辑)是否可以在运行时调整procfile? 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的大小,并且它是可自定义的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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