Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share worker among two different applications on heroku?

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?

like image 335
Sachin Singh Avatar asked Sep 18 '14 08:09

Sachin Singh


People also ask

How do I make my Heroku app public?

When you set an app to public, you make that App accessible to your company users to launch using their Heroku credentials. The Deploy Public Site link on top of the dashboard allows you to deploy a public site.

How do I stop Heroku workers?

That is, log into heroku, go to your app's Resources page, and drag the "Worker Dynos" slider to zero, then save the changes via the "Save and Apply" button on the top-right.


1 Answers

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.

like image 58
Mike Perham Avatar answered Oct 15 '22 16:10

Mike Perham