我的调度程序应用程序运行到 Docker 容器中。
Laravel 调度程序由主管管理并执行到容器中(我通过以下方式管理输出重定向)http://veithen.github.io/2015/01/08/supervisord-redirecting-stdout.html http://veithen.github.io/2015/01/08/supervisord-redirecting-stdout.html):
[supervisord]
nodaemon = true
loglevel = info
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
umask = 022
pidfile = /tmp/supervisord.pid,
logfile = /tmp/supervisord.log
[program:scheduler]
directory = /var/www
command = sh -c 'php artisan schedule:run && sleep 60'
autorestart = true
redirect_stderr = true
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
调整了 My Kernel.php 代码以将输出附加到 stdout_logfile:
$fileCronLog = '/dev/stdout';
$schedule->command('test')->everyMinute()->appendOutputTo($fileCronLog);
测试命令只是将字符串转储到 STDOUT。
如果我将 $fileCronLog 设置为本地存储文件
正确写入文件 $filepath 我的命令输出。
但与
$fileCronLog = '/dev/stdout';
我看不到我的日志。我也尝试进入容器查看这个文件,但它始终是空的。
我可能为我自己的问题找到了解决方案。
这是资源:https://github.com/moby/moby/issues/19616 https://github.com/moby/moby/issues/19616
通过在 Supervisor 将运行的 Dockerfile 中添加此行:
RUN ln -sf /proc/1/fd/1 /var/log/laravel-scheduler.log
然后在 Laravel app/console/Kernel.php 中
$fileCronLog = '/var/log/laravel-scheduler.log';
$schedule->command('test')->everyMinute()->appendOutputTo($fileCronLog);
这是有区别的:
/var/log/laravel-scheduler.log 不应该是 /proc/self/fd/1 的符号链接,
但到/proc/1/fd/1。
“细微但非常显着的差异。”
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)