Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instructions on Supervisor queue installation on Godaddy shared hosting server(Linux)

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.

like image 645
Pankaj Avatar asked Mar 28 '17 02:03

Pankaj


1 Answers

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.

1/ Install beanstalkd

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

2/ Add Pheanstalk package

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

3/ Install supervisor

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.

4/ Make supervisor pick up the changes

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.

like image 96
Sergey Neskhodovskiy Avatar answered Oct 22 '22 09:10

Sergey Neskhodovskiy