Install supervisor by using the following command :
sudo apt-get install supervisor
After you have successfully installed supervisor, you will see a folder “supervisor” inside /etc/ with below mentioned file and folder.
supervisord.conf and conf.d folder
If folder is not created, run this command:
echo_supervisord_conf > /etc/supervisord.conf
Now go to supervisor directory and run the command s below to add the configuration.
Now open laravel-worker.conf file and enter the configuration as per your requirements
command=php <Laravel_Folder_Path>/artisan queue:work --tries=3
Save the file and scroll to the end of supervisord.conf in /etc/supervisor/supervisord.conf and change the path as mentioned below (if not available)
files = /etc/supervisor/laravel-worker.conf
Now, Let’s Start Supervisor to run the queue worker but before that les check if supervisor is already running or not with the command below.
ps -ef to check PID(process ID) and kill to finish the task.
supervisord -c /etc/supervisor/supervisord.conf
Run the following commands one by one after starting supervisor.
sudo supervisorctl reread -- Restart all prgrams in configuration files
sudo supervisorctl update -- Update configurations to supervisord
sudo supervisorctl start laravel-worker:* -- Start a program
To check the status run the command: