Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start Delayed Job with Ubuntu?

I use Delayed Job as a queuing backend for Active Job on my Rails 5 app but I have no idea how to start the worker on Ubuntu 14.04 after startup. Should I wrap rails jobs:work into a Bash script? How would I have it start automatically? Or is it preferable to use bin/delayed_job?

How do I start delayed job on boot?

like image 800
ilovebigmacs Avatar asked Sep 27 '16 08:09

ilovebigmacs


1 Answers

It does not really matter what OS you're on (as long it is not Windows :D).

To start the processing the command is:

bundle exec rake jobs:work

to restart the delayed_job the command is:

RAILS_ENV=production script/delayed_job restart

Check out gems README for more info.

EDIT

(according to the comment)

You can create some bash script in user's home start_delayed_jon.sh.

Something along the lines:

#!/bin/bash
cd /path/to/your/project/directory/
RAILS_ENV=development bundle exec rake jobs:work

and run it in /etc/rc.local:

su -s /bin/bash - deploy /path/to/your/project/directory/start_delayed_jon.sh
like image 55
Andrey Deineko Avatar answered Oct 29 '22 06:10

Andrey Deineko