Version: v0.0.13

Supervisor Configuration

To run the queue worker in production environment, we recommend running the worker using supervisor.

Supervisor is a process monitor for the Linux operating system, and will automatically restart your queue:work process if it fails.

Installing Supervisor

To install Supervisor on Ubuntu, you may use the following command:

sudo apt-get install supervisor

Configuring Supervisor

Supervisor configuration files are typically stored in the /etc/supervisor/conf.d directory. Within this directory, you may create any number of configuration files that instruct supervisor how your processes should be monitored.

/etc/supervisor/conf.d/nest-queue-worker.conf
[program:nestjs_queue_worker]
process_name=%(program_name)s_%(process_num)02d
directory=/home/ubuntu/Sites/your-project/
command=npm run queue:work # or "node /your/project/cli queue:work"
autostart=true
autorestart=true
numprocs=10
user=ubuntu
stderr_logfile=/var/log/nestjs_queue_worker.err.log
stdout_logfile=/var/log/nestjs_queue_worker.out.log

In this example, the numprocs directive will instruct Supervisor to run 10 queue:work processes and monitor all of them, automatically restarting them if they fail.

Starting Supervisor

Once the configuration file has been created, you may update the Supervisor configuration and start the processes using the following commands:

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start nestjs_queue_worker:*

For more information on supervisor, consider the official documentation