4

I am trying to display the output of my Python 3 script (Ubuntu 18.04) under supervisord (4.2.0).

I tried all the solutions listed either in SE (re: flagging for duplicates), or on various forums - among others the two most popular:

  • forcing python to run unbuffered (via the -u switch, or PYTHONUNBUFFERED=TRUE env variable)
  • adding stdout_logfile=/dev/stdout and stdout_logfile_maxbytes=0 to the supervisor config

There is no way for my script to display its output. The script is a one-line file:

~/sup # cat mytest.py
print("hello")

The supervisor configuration:

~/sup # cat myconf.conf
[supervisord]
nodaemon=true
user=root

[program:testingsupervisord]
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
environment=PYTHONUNBUFFERED=1
command=python3 -u mytest.py

When starting supervisor:

~/sup # supervisord -c myconf.conf
2020-05-10 20:02:49,730 CRIT Set uid to user 0
2020-05-10 20:02:49,732 INFO supervisord started with pid 30735
2020-05-10 20:02:50,735 INFO spawned: 'testingsupervisord' with pid 30742
2020-05-10 20:02:50,791 INFO exited: testingsupervisord (exit status 0; not expected)
2020-05-10 20:02:51,795 INFO spawned: 'testingsupervisord' with pid 30744
2020-05-10 20:02:51,837 INFO exited: testingsupervisord (exit status 0; not expected)
2020-05-10 20:02:53,839 INFO spawned: 'testingsupervisord' with pid 30746
2020-05-10 20:02:53,863 INFO exited: testingsupervisord (exit status 0; not expected)
2020-05-10 20:02:56,869 INFO spawned: 'testingsupervisord' with pid 30750
2020-05-10 20:02:56,894 INFO exited: testingsupervisord (exit status 0; not expected)
^C2020-05-10 20:02:57,269 INFO gave up: testingsupervisord entered FATAL state, too many start retries too quickly
2020-05-10 20:02:57,269 WARN received SIGINT indicating exit request

So the script starts, immediately ends after its output and is restarted. The output is never present.

Note: this is also the case when using logging with much more messages, I doubt this is a buffering issue.

WoJ
  • 27,165
  • 48
  • 180
  • 345

0 Answers0