Thursday, December 15, 2016

Running Laravel Queue Listner with Supervisor

Hi

Today, we learn how to run queue listener with supervisor.

To run Laravel's queue listener, we use below command:

 php artisan queue:listen --timeout=60 --tries=3 

However this process won't be restarted when the process ends. So We have to use Supervisor to keep this queue listener process active at all times. Below are instructions for Ubuntu

Install Supervisor with following command

 sudo apt-get install supervisor

Ensure it's started with

 sudo service supervisor restart

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

To create laravel_queue.conf file, run following command

 sudo nano /etc/supervisor/conf.d/laravel_queue.conf

 [program:laravel_queue]
 process_name=%(program_name)s_%(process_num)02d
 command=php /home/username/path_to_laravel/artisan queue:listen --timeout=60 --tries=2
 autostart=true
 autorestart=true 
 user=username 
 stderr_logfile=/var/log/laraqueue.err.log
 stdout_logfile=/var/log/laraqueue.out.log 
 

Now give it execute permissions:

 chmod +x /etc/supervisor/conf.d/laravel_queue.conf

Once the configuration file will be created, we update the Supervisor configuration and start the processes using the following commands:

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

Below 2 command are necessary, whenever we will change our configuration file.

 sudo supervisorctl reread  
 sudo supervisorctl update  

Thanks

4 comments:

  1. Do you want instant solutions related to your Binance technical errors? If yes, you can fix your problems at whatever time and as per your ease. All you have to do is to get in touch with the professionals Binance Support Number who have a plethora of solutions related to the queries. All you need to do is dial Binance customer service number and wash away your queries with their instant help and guidance from the professionals.

    ReplyDelete
  2. Do you want instant solutions related to your Blockchain technical errors? If yes, you can fix your problems at whatever time and as per your ease. All you have to do is to get in touch with the Blockchain Support Number professionals who have a plethora of solutions related to the queries. All you need to do is dial Blockchain customer service number and wash away your queries with their instant help and guidance from the professionals.

    ReplyDelete
  3. Gemini is the platform of crypto exchange where you can invest, save and handle all type of finance things at one place. If you ever encounter any error while using Gemini, you can seek assistance from the specialists who are proficient in dealing with any Gemini Support Number sort of Gemini complexity. To reach the professionals, you can either dial Gemini support phone number or drop your queries via chat. The professionals will be ready with their out-of-the-box solutions.

    ReplyDelete
  4. Do you want to remove duplicated transaction in Binance? Do you know where from you get duplicate transaction in Binance? In order to get an answer for both the above queries, you can discuss your query with the highly-talented professionals by dialing Binance support number. The customer care have a surplus of solutions to all your queries and help in Binance Support Number eliminating your error in quick time. You can contact the customer care anytime as they are available 24/7 to guide.

    ReplyDelete