Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Lowelheim's avatar

queue:work no way to keep it running

Hello all,

I got a problem to keep up running /restart the worker in case something it stops running.

The solution mentions installing Supervisor, which is probably one of the most common practice to solve the issue, problem is my app is running as SaaS in Cloud on Jelastic and in the hosting's marketplace is not included Supervisor and I already had the answer "what it is is what I got".

So, before to take radical actions and evaluate the possibility to migrate the app to another hosting, I would like to know if there are other ways than Supervisor to keep the worker up and running.

Kind regards,

I wish you a fantastic day.

0 likes
1 reply
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

Hello,

If you're unable to use Supervisor on your current hosting platform, there are a few other options you can consider to ensure that your Laravel queue workers are continuously running:

  1. Cron Job: You can set up a cron job that checks if the queue worker is running and starts it if it's not. Here's a simple bash script that you can run as a cron job:
#!/bin/bash

# Check if the queue:work process is running
if pgrep -f "artisan queue:work" > /dev/null
then
    echo "Queue worker is running."
else
    echo "Queue worker is not running. Starting it."
    # Navigate to your Laravel application directory and start the queue worker
    cd /path/to/your/laravel/app
    php artisan queue:work --daemon &
fi

Make sure to replace /path/to/your/laravel/app with the actual path to your Laravel application. You can add this script to your crontab to run at a frequency that suits your needs.

  1. Laravel Task Scheduling: Laravel's task scheduler can be used to ensure that the queue worker is running. You can define a schedule in app/Console/Kernel.php to execute a command that ensures the queue worker is running.
// app/Console/Kernel.php

protected function schedule(Schedule $schedule)
{
    $schedule->call(function () {
        if (!Str::contains(Shell::exec('ps aux | grep "queue:work"'), 'artisan queue:work')) {
            Artisan::call('queue:work');
        }
    })->everyMinute();
}

This approach requires that you have at least one cron entry on your server that executes the schedule:run command every minute.

  1. Third-party Services: There are third-party services like Laravel Forge, Envoyer, or Ploi that provide easy ways to manage queue workers and other server tasks without needing direct access to install software like Supervisor.

  2. Custom Supervisor-like Script: If you have the ability to run long-lived scripts on your server, you could write a custom script in your preferred language that mimics the functionality of Supervisor. This script would monitor the queue worker process and restart it if it fails.

  3. Docker: If Jelastic supports Docker, you could containerize your application and use Docker's restart policies to ensure that your queue worker always restarts if it stops for any reason.

Before implementing any of these solutions, make sure to check with your hosting provider to ensure that they allow such operations and that you won't be violating any terms of service.

Remember that each of these solutions has its own trade-offs and may not be as robust as using a process manager like Supervisor. If keeping your queue workers running reliably is critical to your application, you might want to consider moving to a hosting solution that supports Supervisor or similar tools.

I hope this helps, and I wish you a fantastic day as well!

1 like

Please or to participate in this conversation.