Question

Queue's not process on worker [AppPlatform]

Posted April 22, 2021 743 views
LaravelDigitalOcean App Platform

Ok, I’ve been back and forth with support now 8 times and they don’t understand / see the issue.

  1. Webservice
  2. Worker
  3. Redis Database
  4. MySQL Database

1 and 2 have the same codebase and the same environment variables. The worker component has the following run command(s). It will start the worker process and will schedule the scheduler.

nohup php artisan queue:work --daemon &

while true; do
    echo "=> Running scheduler"
    php artisan schedule:run || true;
    echo "=> Sleeping for 60 seconds"
    sleep 60;
done

In the web service we have created a page to see the queue size. And we are sure that there are items in the queue.

When the worker is started, the jobs are not processed. When I go in the console of the worker and start the process manually, the process starts, but doesn’t process any of the jobs.

When I go into the web service and start the queue:work, it processes the jobs in the queue.

Same code base, (as this is grabbed from GitHub), same env variables. No errors, no logs nothing. The Redis connection seems to be fine.

And yes, the ENV var QUEUE_CONNECTION is set to redis on both applications.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

You may want to try making a bash script with the commands to run, and using that as the run command.

Something like this:

worker.sh

#!/bin/bash
php artisan queue:work --daemon &

while true; do
    echo "=> Running scheduler"
    php artisan schedule:run || true;
    echo "=> Sleeping for 60 seconds"
    sleep 60;
done

And set the run command of the worker to worker.sh

  • I am facing a similar problem, the queue runs for a bit and it stops working after a day. Does anyone know how to solve this?

    • The only way I could solve this was by using MySQL for the jobs instead. Digital Ocean was pushing me back and forth. For another application I didn’t the DO managed DB’s and created a Redis Droplet instead, and that seems to work better.