为什么 supervisord 不记录我的 PHP CLI fwrite(STDOUT, "message")?
Why supervisord does not log my PHP CLI fwrite(STDOUT, "message")?
我有一个 PHP 命令行应用程序 ( zconsole awswebhook运行ner ) 运行 by supervisord.
Supervisord 不记录文件 fwrite(STDOUT, "message")
但它记录 echo "message"
.
监管配置
[program:aws_webhook]
command=/home/(username)/bin/zconsole awswebhookrunner
process_name=%(program_name)s_%(process_num)02d
numprocs=1
directory=/tmp
priority=999
autostart=true
autorestart=true
startretries=100
stopwaitsecs=10
user=(username)
stdout_logfile=/home/(username)/logs/aws_webhook_runner.out.log
stderr_logfile=/home/(username)/logs/aws_webhook_runner.err.log
stdout_logfile_maxbytes=10MB
PHP代码
private function log($message, $type="info")
{
$output=STDIN;
switch ($type) {
case "error":
$output=STDERR;
break;
default:
$output=STDIN;
}
$to_log=date("Y-m-d H:i:s")." ".$message;
fwrite($output,$to_log.PHP_EOL) ;
//echo $to_log.PHP_EOL;
fflush($output);
unset($to_log);
}
软件版本
PHP version: 5.3.3
OS: CentOS 6.10
supervisord: 3.3.5
问题
- 我的
supervisord
设置正确吗?
- 我是否误解了
fwrite(STDOUT|STDERR, $message);
的行为?
- 为什么
echo $message;
在发送到 STDOUT 时有效?
- 配置方面,我觉得还可以。命令方面,这真的是一个不同的问题。
- 您正在尝试
STDIN
而不是 STDOUT
。 STDIN
用于输入 supervisord
我认为不处理 STDIN。
echo
将打印到 STDOUT,因为这是它的默认行为。
我有一个 PHP 命令行应用程序 ( zconsole awswebhook运行ner ) 运行 by supervisord.
Supervisord 不记录文件 fwrite(STDOUT, "message")
但它记录 echo "message"
.
监管配置
[program:aws_webhook]
command=/home/(username)/bin/zconsole awswebhookrunner
process_name=%(program_name)s_%(process_num)02d
numprocs=1
directory=/tmp
priority=999
autostart=true
autorestart=true
startretries=100
stopwaitsecs=10
user=(username)
stdout_logfile=/home/(username)/logs/aws_webhook_runner.out.log
stderr_logfile=/home/(username)/logs/aws_webhook_runner.err.log
stdout_logfile_maxbytes=10MB
PHP代码
private function log($message, $type="info")
{
$output=STDIN;
switch ($type) {
case "error":
$output=STDERR;
break;
default:
$output=STDIN;
}
$to_log=date("Y-m-d H:i:s")." ".$message;
fwrite($output,$to_log.PHP_EOL) ;
//echo $to_log.PHP_EOL;
fflush($output);
unset($to_log);
}
软件版本
PHP version: 5.3.3
OS: CentOS 6.10
supervisord: 3.3.5
问题
- 我的
supervisord
设置正确吗? - 我是否误解了
fwrite(STDOUT|STDERR, $message);
的行为? - 为什么
echo $message;
在发送到 STDOUT 时有效?
- 配置方面,我觉得还可以。命令方面,这真的是一个不同的问题。
- 您正在尝试
STDIN
而不是STDOUT
。STDIN
用于输入supervisord
我认为不处理 STDIN。 echo
将打印到 STDOUT,因为这是它的默认行为。