Queue

Crypterion uses laravel queues which allows the system to defer the processing of a time consuming task, such as sending an email, until a later time. Deferring these time consuming tasks drastically speeds up web requests to your application.

You need to set up a queue worker, which execute jobs immediately they are added into the queue if a queue worker is not setup by default, we use Cron Job setup from the previous page to execute available jobs every minute.

The following steps will guide you using supervisor to setup queue worker

Root access is needed to install the supervisor application on your linux server which will ensure queue is running at all times and auto restart upon failure. To obtain Root Access for cPanel, see SSH Access (root)

Installing Supervisor

Supervisor is a process monitor for the Linux operating system, and will automatically restart your queue:work process if it fails.

To install Supervisor on Ubuntu:

sudo apt-get install supervisor

To install Supervisor on CentOS:

sudo yum install supervisor

Configuring Supervisor

Supervisor configuration files are typically stored in the /etc/supervisor/conf.d directory. Within this directory, you may create any number of configuration files that instruct supervisor how your processes should be monitored. For example, let's create a crypterion-worker.conf file that starts and monitors a queue:work process:

Run the follow commands one after the other:

cd /etc/supervisor/conf.d
sudo nano crypterion-worker.conf

Copy, edit and paste the following file content:

[program:crypterion-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/crypterion/artisan queue:work --tries=1
autostart=true
autorestart=true
user=oluwatosin
numprocs=4
redirect_stderr=true

In this example, the numprocs directive will instruct Supervisor to run 8 queue:work processes and monitor all of them, automatically restarting them if they fail.

Details on the line command=php /var/www/crypterion/artisan queue:work --tries=1 is as follows:

php if you want to use a different php version from the one available in the global scope, you may use the full path to the php location instead. e.g /opt/php71/bin/php

/var/www/crypterion/artisan is the full path to the extracted content of the script. For example in cPanel it may be found in /home/<username>/crypterion/artisan according to the installation procedure where <username> is your cPanel username.

Change the line user=oluwatosin to your username. i.e user=<username>

Starting Supervisor

Once the configuration file has been created, you may update the Supervisor configuration and start the processes using the following commands:

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start crypterion-worker:*