`queue:work` and `schedule:work` not working
Current Behavior
No related output in Laravel log file.
Docker log for queue container:
[20-Mar-2024 08:02:18] NOTICE: fpm is running, pid 118
[20-Mar-2024 08:02:18] NOTICE: ready to handle connections
127.0.0.1 - 20/Mar/2024:08:02:19 +0000 "GET /status" 200
127.0.0.1 - 20/Mar/2024:08:02:19 +0000 "GET /ping" 200
[20-Mar-2024 08:02:23] NOTICE: Terminating ...
[20-Mar-2024 08:02:23] NOTICE: exiting, bye-bye!
Docker log for schedule container:
2024-03-20 08:00:00 Running [App\Jobs\ImportCharges] ............ 123ms FAIL
2024-03-20 08:00:00 Running [App\Jobs\SyncVehicles] ............... 8ms FAIL
2024-03-20 08:00:00 Running [App\Jobs\GenerateBills] .............. 9ms FAIL
Expected Behavior
Queues and Schedules should work. In case of error, it should throw some meaningful error in Laravel log (I don't expect this since the queue and schedules work locally, so this probably isn't a coding issue), or should throw some meaningful error to stdout so we can find it using docker logs.
Steps To Reproduce
- In Production
- Configure queues and scheduler as defined in https://serversideup.net/open-source/docker-php/docs/laravel/laravel-queue
- Neither queue or schedules work
My new docker-compose.prod.yml looks like this:
version: '3.8'
services:
traefik:
networks:
- web-public
ports:
- "80:80"
- "443:443"
# Truncated to make it easy to read
php:
image: ${DEPLOYMENT_IMAGE_PHP} # 👈 Be sure to change this to your own image
networks:
- web-public
volumes:
- "storage_private:/var/www/html/storage/app/private/"
- "storage_public:/var/www/html/storage/app/public/"
- "storage_sessions:/var/www/html/storage/framework/sessions"
- "storage_logs:/var/www/html/storage/logs"
environment:
PHP_POOL_NAME: "my-php-app"
AUTORUN_ENABLED: "true"
AUTORUN_LARAVEL_MIGRATION: "true"
deploy:
replicas: 2
update_config:
parallelism: 1
delay: 5s
order: start-first
labels:
- "traefik.enable=true"
- "traefik.http.routers.my-php-app.rule=${TRAEFIK_HOST_RULE}"
- "traefik.http.routers.my-php-app.entrypoints=websecure"
- "traefik.http.routers.my-php-app.tls=true"
- "traefik.http.routers.my-php-app.tls.certresolver=letsencryptresolver"
- "traefik.http.services.my-php-app.loadbalancer.server.port=80"
- "traefik.http.services.my-php-app.loadbalancer.server.scheme=http"
# Health check
- "traefik.http.services.my-php-app.loadbalancer.healthcheck.path=/ping"
- "traefik.http.services.my-php-app.loadbalancer.healthcheck.interval=100ms"
- "traefik.http.services.my-php-app.loadbalancer.healthcheck.timeout=75ms"
- "traefik.http.services.my-php-app.loadbalancer.healthcheck.scheme=http"
task:
image: ${DEPLOYMENT_IMAGE_PHP}
# Switch to "webuser" before running `php artisan`
# Declare command in list manner for environment variable expansion
# command: ["su", "www-data", "-c", "php artisan schedule:work"]
command: ["php", "artisan", "schedule:work"]
environment:
PHP_FPM_POOL_NAME: "my-app_task"
queue:
image: ${DEPLOYMENT_IMAGE_PHP}
# Switch to "webuser" before running `php artisan`
# Declare command in list manner for environment variable expansion
# command: ["su", "www-data", "-c", "php artisan queue:work --tries=3"]
command: ["php", "artisan", "queue:listen"]
environment:
PHP_FPM_POOL_NAME: "my-app_queue"
# Truncated to keep it short
I tried using
www-dataandwebsuerand neither worked. Without providing any user at least the container runs now without failing, but the core process I need doesn't work - queues and schedules.
Environment
This is from my dev. My issue is with prod and I am not sure how to run
spin debugon prod.
Spin Version:
v2.0.0-beta-3 [stable] (User Installed)
Operating System Version:
ProductName: macOS
ProductVersion: 14.0
BuildVersion: 23A344
Docker Info:
WARNING: Plugin "/Users/mathewparet/.docker/cli-plugins/docker-scan" is not valid: failed to fetch metadata: fork/exec /Users/mathewparet/.docker/cli-plugins/docker-scan: no such file or directory
WARNING: daemon is not using the default seccomp profile
Client:
Version: 25.0.2
Context: desktop-linux
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.12.1-desktop.4
Path: /Users/mathewparet/.docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.24.3-desktop.1
Path: /Users/mathewparet/.docker/cli-plugins/docker-compose
debug: Get a shell into any image or container. (Docker Inc.)
Version: 0.0.22
Path: /Users/mathewparet/.docker/cli-plugins/docker-debug
dev: Docker Dev Environments (Docker Inc.)
Version: v0.1.0
Path: /Users/mathewparet/.docker/cli-plugins/docker-dev
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.21
Path: /Users/mathewparet/.docker/cli-plugins/docker-extension
feedback: Provide feedback, right in your terminal! (Docker Inc.)
Version: v1.0.4
Path: /Users/mathewparet/.docker/cli-plugins/docker-feedback
init: Creates Docker-related starter files for your project (Docker Inc.)
Version: v1.0.0
Path: /Users/mathewparet/.docker/cli-plugins/docker-init
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: /Users/mathewparet/.docker/cli-plugins/docker-sbom
scout: Docker Scout (Docker Inc.)
Version: v1.3.0
Path: /Users/mathewparet/.docker/cli-plugins/docker-scout
Server:
Containers: 16
Running: 6
Paused: 0
Stopped: 10
Images: 21
Server Version: 25.0.2
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
seccomp
Profile: unconfined
cgroupns
Kernel Version: 6.6.12-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: aarch64
CPUs: 8
Total Memory: 7.658GiB
Name: docker-desktop
ID: 4bfe35d7-9697-470f-b1c5-18c9c74fd02c
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5555
127.0.0.0/8
Live Restore Enabled: false
Anything else?
No response
any updates?
Sorry, this was buried in my inbox as I was on paternity leave.
This is more of a question for Docker PHP.
I released v3 since this original post and I would suggest everyone to look here: https://serversideup.net/open-source/docker-php/docs/laravel/laravel-queue
If there are further issues or questions, please open a Discussion on Docker-PHP