🚀 DevOps & SRE Certification Program 📅 Starting: 1st of Every Month 🤝 +91 8409492687 🔍 Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

How to use Supervisor:A Process Control System for Laravel queue in Linux?

Laravel-Queue-Supervisor

How to use Supervisor:A Process Control System for Laravel queue In Linux based OS

What is Supervisor: A Process Control System?

Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems. Supervisor provides you with one place to start, stop, and monitor your processes. Processes can be controlled individually or in groups. You can configure Supervisor to provide a local or remote command line and web interface.


Why do we use Supervisor for Larave Queue?

The supervisor is a process manager which Laravel suggests to use as a process monitor for queue workers. It will automatically start the queue worker in the background, even after the system has booted and will automatically restart the worker if the worker exits unexpectedly.


Steps to Install a Supervisor: A Process Control System for my Laravel Application in Linux based OS.

STEP 1:

Installing Supervisor

Run sudo apt-get install supervisor to install Supervisor

Run service supervisor status to check server is running after installation

supervisor2

STEP 2:

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 mhn-queue.conf file that starts and monitors a queue:work process:

Go to /etc/supervisor

Run ls to cross check the conf.d directory and create your own process file under this directory.

supervisor3

STEP 3:

Let’s consider an example.

Go to /etc/supervisor/conf.d directory and create mhn-queue.conf

To Create mhn-queue.conf run touch mhn-queue.conf

STEP 4:

Open mhn-queue.conf in Vi editor and Write the below code.

[program:mhn-queue]
process_name=%(program_name)s_%(process_num)02d
command=php /home/forge/app.com/artisan queue:work database --sleep=3 --tries=3
autostart=true
autorestart=true
user=forge
numprocs=2
redirect_stderr=true
stdout_logfile=/home/forge/app.com/worker.log
stopwaitsecs=3600

supervisor4


NOTE: change the queue:work database portion of the command directive to reflect your desired queue connection. It could be Redis, sqs in youre application. You can check it in config/queue.php


STEP 5:

Starting Supervisor

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

Run below commands

  • sudo supervisorctl reread
  • sudo supervisorctl update
  • sudo supervisorctl start mhn-queue:*

Referance:

Have a great learning...☺️


Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.