The supervisor will take care of restarting your queue worker whenever its stopped. It’s necessary to restart queue worker on each deploy, so it reflects the code changes.
Login via SSH with root or any user with sudo rights. Install supervisor:
sudo apt-get install supervisor
Create a Supervisor configuration file for your Laravel queue worker. For example, create a file named
laravel-worker.conf in the
sudo nano /etc/supervisor/conf.d/laravel-worker.conf
Add the following configuration, adjusting the paths and options as needed:
command=/opt/plesk/php/8.2/bin/php /var/www/vhosts/yourdomain.com/httpdocs/artisan queue:work
your-usernamewith the username that owns the Laravel project files.
- Ensure that
storage/logsdirectory paths are correct.
- Ensure that your PHP version is correct
Save the file and exit the text editor. Update Supervisor to read the new configuration:
sudo supervisorctl reread
sudo supervisorctl update
Start the Laravel worker process with Supervisor:
sudo supervisorctl start laravel-worker
You can check the status of the worker:
sudo supervisorctl status
Add to deploy script
Add a supervisorctl restart command in your deploy script. Assuming you using PLESK GIT Deploy tool, you would add it here:
However, your deployment script will be called from the user of your web subscription (which is good, because your vendor folder etc. should have same access rights). THe supervisorctl is by default only runnable if you have sudo rights.
To do this, edit the configuration file from supervisor (mine is at
/etc/supervisor/supervisord.conf) In the
[unix_http_server] section of the configuration, you can use the
chown directive to control access to the UNIX domain socket. For example:
Save the changes to the Supervisor configuration file. Restart the Supervisor service to apply the changes:
sudo service supervisor restart
Now your deployment script should work. Enjoy!