Where is your app located? Are you sure in /var/www/app/? You can see the full path inside of your project with the command pwd
Supervisor configuration: Could not open input file: ../artisan
I followed official Laravel Docs to configure Supervisor. But I am stuck at granting supervisor access to the artisan command.
/etc/supervisor/conf.d/laravel-worker.conf:
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/app/artisan queue:work database --sleep=3 --$p=3 --tries=3 --daemon
user=usr
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/app/worker.log
After running supervisorctl reread, updated and start I checked status with: sudo supervisorctl status which returns:
laravel-worker:laravel-worker_00 FATAL Exited too quickly (process log may have details)
/var/www/app/worker.log:
Could not open input file: /var/www/app/artisan
Could not open input file: /var/www/app/artisan
Could not open input file: /var/www/app/artisan
Could not open input file: /var/www/app/artisan
How to make this work?
As I supposed it had to do with permissions. Here is the source of the solution. The following procedure solved it for me:
First remove supervisor and its config files:
sudo apt remove supervisor
sudo rm -rf /etc/supervisor
Then reinstall:
sudo apt install supervisor
Create user group supervisor and add the user to it that owns the app:
sudo groupadd supervisor
sudo usermod -a -G supervisor usr
Probably the status check will fail (sudo service supervisor status) since there is no (valid) /etc/supervisor/supervisord.conf.
That is why we need to create/adjust one:
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0770 ; sockef file mode (default 0700)
chown=root:supervisor
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.
[include]
files = /etc/supervisor/conf.d/*.conf
Restart supervisor and check if service is running:
sudo service supervisor restart
sudo service supervisor status
If it is running without errors you are ready to go to make your worker conf:
sudo nano /etc/supervisor/conf.d/laravel-worker.conf
And add your configuration
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=sudo php /var/www/app-dir/artisan queue:work --tries=3 --daemon -vvv
user=usr
autostart=true
autorestart=true
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/app-dir/storage/logs/worker.log
Finally:
supervisorctl reread
supervisorctl update
supervisor status
If everthing is fine something like this should be returned:
laravel-worker:queue_00 RUNNING pid 2093, uptime 0:01:46
Please or to participate in this conversation.