laravel - 如何使用 Laravel 队列记录标准输出和标准错误:在 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
队列工作者运行良好,但存在一个问题。我没有将我的标准输出和标准错误记录到文件中。
在使用 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
推荐阅读
- python - 如何确保我的代码使用 GPU 的全部容量?
- c# - C# 编译错误:无法从 *.csproj 文件中找到 main
- spring-webflux - 项目反应堆。Mono.map() 与 Mono.flatMap()
- processing - 我的球移动不顺畅,但有口吃。如何实现更流畅的运动?
- apache-spark - 来自databricks的apache.avro和spark-avro之间的区别
- sql - 在 SSIS 中使用 case 语句
- r - 随机森林模型的输出值是否可以接受?
- azure-cognitive-services - southasia.api.cognitive.microsoft.com 无法正常工作
- java - 无法将附件添加到新的 RT 票证
- react-native - 在文本组件中嵌套视图组件不起作用 react-native 0.60-RC