1

I have a very simple python program I am running in supervisord.

The supervisord.conf is completely default besides the program section:

[program:logwatcher]
command=/path/to/python -u "/path/to/logwatcher.py"

The python code:

import sys

print("print\n")
print("file=sys.stdout\n", file=sys.stdout)
print("file=sys.stderr\n", file=sys.stderr)
sys.stdout.write("sys.stdout.write\n")
sys.stderr.write("sys.stderr.write\n")

Produces this output:

supervisor> tail logwatcher
print
file=sys.stdout
sys.stdout.write

supervisor> tail logwatcher stdout
file=sys.stderr
sys.stderr.write

supervisor> tail logwatcher stderr
file=sys.stderr
sys.stderr.write

why is tail stdout only showing stderr messages, and not stdout messages?

why is tail stdout showing stderr at all?

if tail is supposed to mimic tail stdout why don't they match?

tested on supervisor 3.3.5 and supervisor 4.0.1

Jonathan
  • 31
  • 1
  • 4
  • What part confuses you in particular? `print` usually prints to `sys.stdout` (i.e. `print()` and `print(file=sys.stdout)` will usually do the same thing unless overridden for some reason (which is very rarely done). `sys.stderr` is where errors are printed. For example if you did `raise ValueError` the resulting message will be printed to `sys.stderror`. For your typical user `stderror` and `stdout` our usually not used; however, some programs redirect those streams for logging purposes. Here is an example of a redirect: [send print to file](https://stackoverflow.com/a/4110906/8150685) – Error - Syntactical Remorse Apr 13 '19 at 23:28
  • why is tail stdout only showing stderr messages, and not stdout messages? why is tail stdout showing stderr at all? if tail is supposed to mimic tail stdout why don't they match? – Jonathan Apr 13 '19 at 23:35
  • https://stackoverflow.com/questions/11392001/how-does-supervisorctl-tail-work-for-a-given-process – Jonathan Apr 13 '19 at 23:41
  • Interesting. Can you add `flush=True` to your print statements and see what that prints? Assuming you are using python3.3+. – Error - Syntactical Remorse Apr 14 '19 at 00:23
  • so originally I wasn't getting anything to show up in tail at all, but then I used flush=True and then it showed up. I got around having to do that on each print statement by running python -u which makes the output unbuffered – Jonathan Apr 14 '19 at 00:34
  • It may just be a bug. It looks like an issue was posted back it 2012 but it is still open [supervisorctl should print errors to stderr, not to stdout](https://github.com/Supervisor/supervisor/issues/170) – Error - Syntactical Remorse Apr 14 '19 at 00:42

0 Answers0