Search code examples
phploggingsupervisordgearman

Supervisor std out log is empty when executing shell script for command


My supervisor log is empty and I don't know what to do to populate it. I have a simple test bash script

#!/usr/bin/env bash

echo "STARTING SCRIPT"

while read LINE
do
    echo ${LINE} 2>&1
done < "${1:-/dev/stdin}"

exit 0

And my supervisor.conf

[unix_http_server]
file=/tmp/supervisor.sock

[supervisord]
logfile=/var/log/supervisor/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=/var/run/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200
umask=022
nocleanup=false

[rpcinterface:supervisor]
supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock

[program:print-lines]
command=gearman -h 127.0.0.1 -p 4730 -w -f print-lines -- /var/www/html/myapp/bash/printlines.sh 2>&1
process_name=print-lines-worker
numprocs=1
startsecs = 0
autorestart = false
startretries = 1
user=root

stdout_logfile=/var/www/html/myapp/var/log/supervisor_print_lines_out.log 
stdout_logfile_maxbytes=10MB
stderr_logfile=/var/www/html/myapp/var/log/supervisor_print_lines_err.log
stderr_logfile_maxbytes=10MB

Then I execute this job via php script

$gmClient= new GearmanClient();
$gmClient->addServer();
# run reverse client in the background
$jobHandle = $gmClient->doBackground("print-lines", $domains);
var_dump($jobHandle);

So what happens is following. Job gets executed

myapp-dev: /var/www/html/myapp $ gearadmin --status
print-lines 1   1   1

But both of log files are empty... I would at least expect that somewhere would be written "STARTING SCRIPT" or something, but everything is empty.

What Am I Doing Wrong? Am I checking wrong log file?

If you need any additional informations, please let me know and I will provide. Thank you


Solution

  • I found a solution or at lease a workaround. What I did is following

    my supervisor.conf command now looks like this

    command=gearman -h 127.0.0.1 -p 4730 -w -f print-lines -- bash -c "/var/www/html/myApp/bash/printlines.sh > /var/www/html/myApp/var/log/printlines.log  2>&1"
    

    So shell is now writing a log file when shell script gets executed