如何使用Laravel队列记录stdout和stderr:在docker容器中工作



我的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

队列工作者工作得很好,但有一个问题。我没有将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: AppEventsMatchOfDayOnlinePoint
[2019-12-06 10:47:46][grpE4prmKGTyW7Qgj2XI8WhMGv0jOa8r] Processed:  AppEventsMatchOfDayOnlinePoint
[2019-12-06 10:48:01][k5sMBerEzKSa2UJ3isFwUywIMOtgfsRs] Processing: AppJobsRatioJob
[2019-12-06 10:48:07][k5sMBerEzKSa2UJ3isFwUywIMOtgfsRs] Processed:  AppJobsRatioJob

我试着用

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

最新更新