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.
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
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
Run the follow commands one after the other:
cd /etc/supervisor/conf.dsudo nano crypterion-worker.conf
Copy, edit and paste the following file content:
[program:crypterion-worker]process_name=%(program_name)s_%(process_num)02dcommand=php /var/www/crypterion/artisan queue:work --tries=1autostart=trueautorestart=trueuser=oluwatosinnumprocs=4redirect_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
/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
Once the configuration file has been created, you may update the Supervisor configuration and start the processes using the following commands:
sudo supervisorctl rereadsudo supervisorctl updatesudo supervisorctl start crypterion-worker:*