-1

I have a PHP command line application ( zconsole awswebhookrunner ) run by supervisord.

Supervisord does not log on the files fwrite(STDOUT, "message") but it does log echo "message".

Supervisord config

[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 Code

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);
}

Software version

PHP version: 5.3.3
OS: CentOS 6.10
supervisord: 3.3.5

Questions

  1. Is my supervisord setup correct?
  2. Do I have a misunderstood the behavior of fwrite(STDOUT|STDERR, $message);?
  3. Why echo $message; works if it is sent to STDOUT?
2
  • 1
    $output=STDIN; are you sure this is what you want?
    – yivi
    Feb 22, 2019 at 14:41
  • 2
    Should be STDOUT and not sure in php 5.3 now but I would do fopen('php://stdout', 'w').
    – Starx
    Feb 22, 2019 at 15:27

1 Answer 1

0
  1. Configuration wise, I think it is fine. Command-wise, it's a different question really.
  2. You are trying to STDIN rather than STDOUT. STDIN is used for input supervisord does not deal with STDIN I think.
  3. echo would print to STDOUT because it is its default behavior.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.