我的docker-compose.yml
&app-service app: &app-service-template
container_name: k4fntr_app
build:
context: ./docker/php-fpm
args:
UID: ${UID?Use your user ID}
GID: ${GID?Use your group ID}
user: "${UID}:${GID}"
hostname: *app-service
volumes:
- /etc/passwd/:/etc/passwd:ro
- /etc/group/:/etc/group:ro
- ./:/var/www/k4fntr
environment:
FPM_PORT: &php-fpm-port 9000
FPM_USER: "${UID:-1000}"
FPM_GROUP: "${GID:-1000}"
command: ./docker/php-fpm/sh/keep-alive.sh
depends_on:
- redis
- database
networks:
- backend-network
&queue-service queue:
<<: *app-service-template
container_name: k4fntr_queue
restart: always
hostname: *queue-service
command: php artisan queue:work --sleep=3 --tries=3
队列 worker 工作得很好,但是有一个问题。我没有将我的stdout和stderr记录到文件中。
在使用docker之前,我有一个主管实例
[program:fntr-worker]
command=php /k4fntr/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
user=apache
startretries=9999999
numprocs=1
stdout_logfile=/k4fntr/storage/logs/fntr-worker.stdout.log
stderr_logfile=/k4fntr/storage/logs/fntr-worker.stderr.log
并可以看到我的工作日志
[2019-12-06 10:47:46][grpE4prmKGTyW7Qgj2XI8WhMGv0jOa8r] Processing: App\Events\MatchOfDayOnlinePoint
[2019-12-06 10:47:46][grpE4prmKGTyW7Qgj2XI8WhMGv0jOa8r] Processed: App\Events\MatchOfDayOnlinePoint
[2019-12-06 10:48:01][k5sMBerEzKSa2UJ3isFwUywIMOtgfsRs] Processing: App\Jobs\RatioJob
[2019-12-06 10:48:07][k5sMBerEzKSa2UJ3isFwUywIMOtgfsRs] Processed: App\Jobs\RatioJob
我尝试使用
command: nohup php artisan queue:work --sleep=3 --tries=3 > app/storage/logs/laravel.log 2&>1
但我的容器因错误而失败
最佳答案
这可能是解决方案stdout_logfile=./k4fntr/storage/logs/fntr-worker.stdout.log
关于laravel - 如何使用Laravel队列记录stdout和stderr:在Docker容器中工作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/60522981/