Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running delayed_job worker on Heroku?

So right now I have an implementation of delayed_job that works perfectly on my local development environment. In order to start the worker on my machine, I just run rake jobs:work and it works perfectly.

To get delayed_job to work on heroku, I've been using pretty much the same command: heroku run rake jobs:work. This solution works, without me having to pay anything for worker costs to Heroku, but I have to keep my command prompt window open or else the delayed_job worker stops when I close it. Is there a command to permanently keep this delayed_job worker working even when I close the command window? Or is there another better way to go about this?

like image 466
Danish M. Avatar asked Jul 24 '12 06:07

Danish M.


3 Answers

I recommend the workless gem to run delayed jobs on heroku. I use this now - it works perfectly for me, zero hassle and at zero cost.

I have also used hirefireapp which gives a much finer degree of control on scaling workers. This costs, but costs less than a single heroku worker (over a month). I don't use this now, but have used it, and it worked very well.

like image 78
Damon Mannion Avatar answered Oct 20 '22 22:10

Damon Mannion


Add

worker: rake jobs:work

to your Procfile.

EDIT:

Even if you run it from your console you 'buy' worker dyno but Heroku has per second biling. So you don't pay because you have 750h free, and month in worst case has 744h, so you have free 6h for your extra dynos, scheduler tasks and so on.

like image 37
Hauleth Avatar answered Oct 20 '22 22:10

Hauleth


I haven't tried it personally yet, but you might find nohup useful. It allows your process to run even though you have closed your terminal window. Link: http://linux.101hacks.com/unix/nohup-command/

like image 35
Benjamin Tan Wei Hao Avatar answered Oct 20 '22 22:10

Benjamin Tan Wei Hao