To ensure that both your Laravel queue workers and the Reverb server are running continuously on your Digital Ocean server using Supervisor, you'll need to create Supervisor configuration files for each process. Here's a step-by-step guide:
-
Install Supervisor: If you haven't already installed Supervisor on your server, you can do so using the following command:
sudo apt-get update sudo apt-get install supervisor -
Configure Supervisor for Laravel Queue: Create a configuration file for your Laravel queue worker. You can typically find Supervisor configuration files in
/etc/supervisor/conf.d/. Create a new file, for example,laravel-worker.conf:[program:laravel-worker] process_name=%(program_name)s_%(process_num)02d command=php /path/to/your/laravel/artisan queue:work --sleep=3 --tries=3 autostart=true autorestart=true user=yourusername numprocs=1 redirect_stderr=true stdout_logfile=/path/to/your/laravel/storage/logs/worker.logReplace
/path/to/your/laravelwith the actual path to your Laravel application andyourusernamewith the user that should run the process. -
Configure Supervisor for Reverb: Similarly, create a configuration file for the Reverb server, for example,
reverb-server.conf:[program:reverb-server] command=php /path/to/your/laravel/artisan reverb:start --port=6001 autostart=true autorestart=true user=yourusername redirect_stderr=true stdout_logfile=/path/to/your/laravel/storage/logs/reverb.logAgain, replace
/path/to/your/laravelandyourusernamewith the appropriate values. -
Update Supervisor: After creating these configuration files, update Supervisor to recognize the new configurations:
sudo supervisorctl reread sudo supervisorctl update -
Start the Processes: You can start the processes using Supervisor with the following commands:
sudo supervisorctl start laravel-worker:* sudo supervisorctl start reverb-server -
Verify the Setup: Check the logs specified in the configuration files to ensure that both the queue worker and the Reverb server are running without issues.
By following these steps, you should have both your Laravel queue workers and the Reverb server running continuously on your Digital Ocean server, managed by Supervisor. This setup will ensure that both services restart automatically if they fail or if the server reboots.