Cookie Settings

This site uses cookies that need consent. Learn more

Skip to content
Tooling

Forge: How to restart a queue:worker or deamon via deployment-script


Sometimes there are problems with the queue. It can happen that the database connection of the Redis worker breaks down, which makes it necessary to restart the queue worker.

This error pattern is shown by the logging of the Redis worker:

In Connection.php line 825:
                                                                               
  SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select *  
   from `cache` where `key` in (illuminate:queue:restart))                     
                                                                               

In Connector.php line 66:
                                             
  SQLSTATE[HY000] [2002] Connection refused

Using the Forge Scheduler, the Redis worker can be restarted every night with a simple command. This improves the autonomous stability of the web app.

Command to restart cues or deamons:

sudo -S supervisorctl restart worker-5432987:worker-5432987_00

The ID of the queue worker or deamon can be found via the status dialogue (button: ‘Check Worker Status’):

Laravel Forge Redis Worker Status Dialog.

A dialogue like the following will then be displayed, in which you can see the name of the worker.

Laravel Forge: Check Queue and Deamon ID for restart via Deployment Script.

We now add the command (sudo -S supervisorctl restart worker-5432987:worker-5432987_00) to the Forge Scheduler for nightly execution:

Laravel Forge: Restart Redis via Forge Scheduler.

This command can also be placed in the deployment script.