Introducing Cloudways Community Forum. Start Discussions and Get Instant Help From Cloudways Community. JOIN NOW

How to Install and Configure Supervisord on CloudwaysSeptember 29, 2017

 

In this KB

  • What is Supervisord
  • How to Install Supervisord and use it for Laravel
  • How to view job status

This guide will assist you in learning about Supervisord and how you could install it for your Laravel applications.

What is Supervisord?

Supervisord is a simple, fast worker manager, designed to monitor and control the processes which allows you to defer the processing of a time consuming task to speed up the web requests to your application.

Note: Supervisord is only available Laravel apps deployed with Laravel or Custom PHP Stacks.

Step 1: Installing Supervisord

Go to Server Management, then Settings & Packages, and then access the Packages section. Click on the Install button next to Supervisord to start the installation process.

image1

Before the process starts, you will be asked to install Redis on the server (if it is not already installed), as it is required for Laravel queues. Wait for the installation process to finish.

image2

Note: You can check Supervisord service status from Manage Services section, and also Restart the service, if required.

Step 2: Supervisord Application Prerequisites

Note: This process describes the configuration when Redis is used as the default driver. You need to configure your application to use Redis.

After installation, you need to carry out application configuration changes so that Redis could be used as the queue driver. To do that, first it is required to install predis/predis package for Laravel with Composer.

Connect to server via SSH terminal, then go to your application directory webroot (/home/master/applications/<app folder>/public_html/) and run this command:

composer require predis/predis

Once it is installed, next you need to configure it in the application. For that, edit the /home/master/applications/public_html/.env file in your application as follows:

Change From: QUEUE_DRIVER=sync
Change to: QUEUE_DRIVER=redis

Next, edit the /home/master/applications/public_html/config/queue.php file as follows:

Change From: ‘default’ => env(‘QUEUE_DRIVER’, ‘sync’),
Change To: ‘default’ => env(‘QUEUE_DRIVER’, redis’),

After these changes are saved in the Laravel application, proceed to the next step.

Step 3: Add New Job

Under Application Management, go to Application Settings and select the tab for Supervisor Jobs. Click on Add New Job button to add a job for Supervisord.

image4

The various Laravel queue related options are briefly explained below:

Connection Driver: Redis is used as the queue driver where the jobs will be held as configured in Step 2.

Number of process: Number of processes control how many processes supervisord will run at the same time. The default value is 1.

Timeout: The timeout option specifies how long the Laravel queue master process will wait before killing off a child queue worker that is processing a job.

Sleep Time: Sleep time option determines how long the worker will “sleep” if there are no new jobs available. While sleeping, the worker will not process any new jobs – the jobs will be processed after the worker wakes up again.

Queue: The names of the queues to work

Maximum Tries: Maximum number of tries after which the job is logged as a fail

Environment (Optional): The environment the command should run under

Artisan Path: Add custom Artisan path or leave unchanged for default

Fill in the required details and click the Save button.

image5

Step 4: Job Status and other options

The job status can be checked by clicking the Jobs Status button.

image3

This will show the status of job and other related information including uptime.

If you want to restart any job, click the icon in front of it. There is also the option of removing any job by clicking the remove icon.

image6

 You now know how to install and use Supervisord on Cloudways with your Laravel app.

 

Important Notes:

  • You can check the job logs in the following path: /home/master/applications/<app folder>/logs/<appname_jobID>.log
Have Questions? Ask From Our Helpful Community

Comments are closed.

Still need help? Our support team is waiting to help you. Ask them now