Can somebody share step by step instructions on Supervisor queue installation on Godaddy shared hosting server? I tried to search and alot but could not find one.
The process to install supervisor will depend on the OS version your server is running. You can find out your OS by following advice on this page.
In any case you will need SSH access to run commands in terminal and sudo / root privileges.
Here's an outline for Debian / Ubuntu OS.
Install beanstalkd (the daemon that will handle queues):
(note: you can skip this step, if you are going to use some simple queue driver instead, like "sync" or "database" - in this case, be sure to replace "beanstalkd" further along this guide, namely in supervisor config file section)
sudo apt-get install beanstalkd
sudo nano /etc/default/beanstalkd
uncomment this line:
START=yes
start the service:
sudo service beanstalkd start
In your Laravel app, add Pheanstalk package to talk to beanstalkd:
(skip this step if you are not using beanstalkd driver)
cd /my/laravel/app/dir
composer require pda/pheanstalk
sudo apt-get install supervisor
make sure it starts with the server
sudo service supervisor restart
Create a supervisor configuration file for your laravel app
sudo nano /etc/supervisor/conf.d/myapp.conf
Here's a sample file, it will start 2 threads listening to your queue. Each job will be tried maximum 3 times before failing eventually. Make sure to change user and paths to match your laravel directory and server user.
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /my/laravel/app/dir/artisan queue:work beanstalkd --tries=3
autostart=true
autorestart=true
user=forge
numprocs=2
redirect_stderr=true
stdout_logfile=/my/laravel/app/dir/storage/logs/worker.log
Consult https://laravel.com/docs/master/queues#running-the-queue-worker for details on other options that can be configured here.
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl restart laravel-worker:*
5/ That's all, try dispatching a job to the default queue, check your laravel log for any errors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With