如何在heroku上的两个不同的应用程序中共享工作人员? [英] How to share worker among two different applications on heroku?

查看:107
本文介绍了如何在heroku上的两个不同的应用程序中共享工作人员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个独立的应用程序在heroku上运行,并指向同一个数据库,第一个负责用户界面,第二个负责管理界面,我使用 sidekiq redis 来处理后台作业,我添加了一个工作人员和I我可以通过设置指向相同Redis提供Addon的环境变量来共享'redis-server',现在我也希望共享工作人员,因为增加额外的工作人员将花费翻倍。



<请建议,这是否可能与否? 如果两个应用程序使用相同的Redis URL和相同的命名空间,则可以使用相同的Redis配置启动一个工作人员,它会被两者共享。



请注意,您的Sidekiq进程将启动一个应用程序或另一个应用程序。您的工作人员的代码必须在该应用程序中。其他应用程序将无法引用代码,但可以使用以下方式推送作业:

  Sidekiq :: Client.push(' class'=>'SomeWorker','args'=> [1,2,3])



<请注意'class'是一个字符串,因此SomeWorker实际上可以在其他应用程序中定义。


I have two separate applications running on heroku and pointing to same database, first one responsible for user interfaceand second one for admin interface, I am using sidekiq with redis for background job processing, I have added one worker and I am able to share 'redis-server' by setting environment variable pointing to same Redis providing Addon, Now i wish to share worker too, because adding the extra worker will cost double.

Please suggest, whether this is even possible or not?

解决方案

If both apps are using the same Redis URL and same namespace, you can spin up one worker with that same Redis config and it will be shared by both.

Note that your Sidekiq process will boot one app or the other. The code for your Workers must be in that app. The other app won't be able to reference the code but can push jobs using:

Sidekiq::Client.push('class' => 'SomeWorker', 'args' => [1,2,3])

Note that 'class' is a String so SomeWorker can actually be defined in the other app.

这篇关于如何在heroku上的两个不同的应用程序中共享工作人员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆