Binu
Binu

Reputation: 23

How to run delayed_jobs in production environment

I am using delayed_job in rails application development and in development environment i use bin/delayed_job start

But how to do the same in production environment?

Upvotes: 2

Views: 2409

Answers (3)

Tomislav Štajduhar
Tomislav Štajduhar

Reputation: 23

In case someone else gets stuck with -bash: bin/delayed_job: Permission denied error as Disha did in comments above, for Centos it is enough to set delayed_job in bin/ folder in your project's directory to executable.

Upvotes: 0

Alfie
Alfie

Reputation: 2784

RAILS_ENV=production bin/delayed_job start

This should make the delayed jobs run in production env

Upvotes: 2

shivam
shivam

Reputation: 16506

To start:

cd /home/user/app;
bundle exec /usr/bin/env RAILS_ENV=production /home/user/app/script/delayed_job start

To stop:

cd /home/user/app; 
bundle exec /usr/bin/env RAILS_ENV=production /home/user/app/script/delayed_job stop

Refer to official documentation at github.

RAILS_ENV=production script/delayed_job start
RAILS_ENV=production script/delayed_job stop

# Runs two workers in separate processes.
RAILS_ENV=production script/delayed_job -n 2 start
RAILS_ENV=production script/delayed_job stop

# Set the --queue or --queues option to work from a particular queue.
RAILS_ENV=production script/delayed_job --queue=tracking start
RAILS_ENV=production script/delayed_job --queues=mailers,tasks start

# Use the --pool option to specify a worker pool. You can use this option multiple times to start different numbers of workers for different queues.
# The following command will start 1 worker for the tracking queue,
# 2 workers for the mailers and tasks queues, and 2 workers for any jobs:
RAILS_ENV=production script/delayed_job --pool=tracking --pool=mailers,tasks:2 --pool=*:2 start

# Runs all available jobs and then exits
RAILS_ENV=production script/delayed_job start --exit-on-complete
# or to run in the foreground
RAILS_ENV=production script/delayed_job run --exit-on-complete

Upvotes: 1

Related Questions