This is just an add-on to running queue worker on Azure. If you want to run scheduler, first you need to get familiar with that document and fullfill the environment file update requirement for Supervisor (in the document above it's done by adding EnvGenerate
command and running it on startup). After that, you need to create Supervisor configuration and run it on startup.
⚠️ This is a very poorly tested solution and the stability of it is currently unknown. Use at your own risk.
⚠️ ALSO: this instruction was created for a very specific case, yours is probably different.
⚠️ ALSO ALSO: Laravel's documentation does not encourage running schedule worker on production environments, it rather suggests it was created for local development environments. From my experience it seems to work the same asschedule:run
ran fromcron
, but if you want an expert opinion, ask someone from IT, I am just a humble carpenter.
Add a laravel-scheduler.conf
to your project in the main directory. Example working content:
[program:laravel-scheduler]
directory=/home/site/wwwroot
process_name=%(program_name)s_%(process_num)02d
command=php artisan schedule:work
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/home/site/wwwroot/storage/logs/scheduler.log
Changes made, compared to running queue worker:
- number of processes (
numprocs
) changed to 1 - Supervisor won't kill process if it still runs (
stopwaitsecs
removed) - working
directory
added (Laravel's schedule worker seems to call Artisan every time and without it, it wouldn't find it)
This is what you need to add at the end of your deployment slot's Startup Command (Configuration->General) if you did not follow all steps from mentioned queue-related document (because you didn't need queue worker, just scheduler). If you need both queue worker and scheduler, you will need to merge the commands (copying config file and running Supervisor program).
&& apt install supervisor -y && cp /home/site/wwwroot/laravel-scheduler.conf /etc/supervisor/conf.d && service supervisor start && supervisorctl reread && supervisorctl update && supervisorctl start laravel-scheduler:*