docker-php icon indicating copy to clipboard operation
docker-php copied to clipboard

Laravel Scheduler/Queue Worker HEALTHCHECK Fails (Docs Bug?)

Open tsterker opened this issue 1 year ago • 0 comments

Steps To Reproduce

  • Follow the docs for starting a queue worker: https://serversideup.net/open-source/docker-php/docs/laravel/laravel-queue
  • See the container being shown as unhealthy:
docker ps
docker inspect <container>

Outcome

What did you expect?

As per the docs it is mentioned that we are intentionally re-using the same app image:

Notice we're using the same my/laravel-app image for both the PHP and Queue services. This is a common practice to keep the image consistent.

So, I would expect that there is either

  • (A) A way to disable the stock healthcheck
  • (B) Documentation that we need to disable the health check when not running our app as HTTP service

What happened instead?

If followed the docs and got an unhealthy container.

Affected Docker Images

Tested with serversideup/php:8.3-unit-v3.2.0

Anything else?

Solution / Workaround

As a quick fix, we can simply disable the healthcheck:

  task:
    build:
      context: .
    command: ["php", "/var/www/html/artisan", "schedule:work"]
+   healthcheck: { test: ['NONE'] }
    volumes:
      - .:/var/www/html

I wonder if there are somewhat clean ways to introduce a dedicated healthcheck that could properly/cleanly determine if the queue worker is healthy.

tsterker avatar Jul 02 '24 15:07 tsterker