sudo apt-get install supervisor
Supervisor configuration files typically live in a /etc/supervisor/conf.d directory. For example, you can create a new messenger-worker.conf file there to make sure that 2 instances of messenger:consume are running at all times:
;/etc/supervisor/conf.d/messenger-worker.conf
[program:messenger-consume]
command=php /path/to/your/app/bin/console messenger:consume async --time-limit=3600
user=ubuntu
numprocs=2
startsecs=0
autostart=true
autorestart=true
process_name=%(program_name)s_%(process_num)02d
Change the async argument to use the name of your transport (or transports) and user to the Unix user on your server. Next, tell Supervisor to read your config and start your workers:
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start messenger-consume:*