Install Supervisor:
sudo apt-get install supervisor
Create a new configuration file for your Laravel task scheduler in the /etc/supervisor/conf.d/ directory. The file should be named laravel-worker.conf
Add the following configuration to the file:
Copy code
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /path/to/your/laravel/installation/artisan schedule:run
autostart=true
autorestart=true
user=www-data
redirect_stderr=true
Replace /path/to/your/laravel/installation/ with the actual path of your Laravel installation.
Update the Supervisor's configuration by running the command:
Copy code
sudo supervisorctl reread
Start the Laravel task scheduler process by running the command:
Copy code
sudo supervisorctl start laravel-worker
With this configuration, Supervisor will start the Laravel task scheduler process when the server boots, and it will automatically restart the process if it crashes. It also keeps track of the process and log any errors that may occur.
You can also use sudo supervisorctl stop laravel-worker to stop the process or sudo supervisorctl status laravel-worker to check the status of the process.
You can also use sudo supervisorctl tail -f laravel-worker to see the logs of the process
Note: Make sure you have supervisor installed in your server and you have the correct permissions to manage the process.
Also, make sure your Nginx server have the correct permissions to execute the cron job, and also make sure that your laravel application have the correct permissions to write to log files, cache and other necessary files.
To restart Supervisor, you can use the following command:
sudo service supervisor restart
Alternatively, you can also use the following command:
sudo systemctl restart supervisor
This command is used to restart the supervisor service on systems that use systemd.
You can also use the following command to check the status of the Supervisor service:
sudo service supervisor status
or
sudo systemctl status supervisor
This command will show you if the service is running or not and if there are any errors.
Please note that after restarting supervisor, you will need to update the process by running the following command:
sudo supervisorctl update
Shut the fuck off
ReplyDelete