Yarin
Yarin

Reputation: 183989

Can't get output of supervisord monitored process

I created a test executable to see if I could capture the output of a program monitored by Supervisord.

tester.py:

#! /usr/bin/env python

import time, os
pid = os.getpid()
print "EXECUTING ON %s" % pid
while True:
    time.sleep(5)
    print "HOLLER %s" % pid

supervisord.conf:

[program:mytester]
command={path}/tester.py

But when I try to run a tail on the process in supervisorctl, nothing.

Upvotes: 3

Views: 1530

Answers (1)

pacha
pacha

Reputation: 3007

It's been a while since you asked, but in case you are still interested and for anyone that has this same problem:

In this case Python is buffering the output and you will not see it until is flushed to stdout. You can force a flush with sys.stdout.flush() in your program, but probably the cleanest way of fixing it is to run your script in unbuffered mode with the -u flag of the Python interpreter:

supervisord.conf

[program:mytester]
command=python -u {path}/tester.py

(Had the same problem and found the solution in supervisord's mailing list)

Upvotes: 4

Related Questions