Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tail bug #1252

Merged
merged 1 commit into from Jun 16, 2019

Conversation

2 participants
@aruseni
Copy link
Contributor

commented Jun 12, 2019

The bug was that when the channel was explicitly specified, it always
evaluated to stderr, i.e. supervisorctl tail foo stdout and
supervisorctl tail foo stderr were both showing stderr.
That is because we should not use is for such comparisons:
these two are different objects.

If curious, read more here: https://stackoverflow.com/questions/1504717/

This just changes the tail command to use == for comparing the two objects.

Fix tail bug
The bug was that when the channel was explicitly specified, it always
evaluated to stderr, i.e. supervisorctl tail foo stdout and
supervisorctl tail foo stderr were both showing stderr.
That is because we should not use is for such comparisons:
these two are different objects.

If curious, read more here: https://stackoverflow.com/questions/1504717/

This just changes the tail command to use == for comparing the two objects.
@mnaberez

This comment has been minimized.

Copy link
Member

commented Jun 13, 2019

The bug was that when the channel was explicitly specified, it always evaluated to stderr

Here's what I tried to reproduce this.

Python script to print on stdout and stderr:

import sys
import time

while True:
  sys.stderr.write('stderr ')
  sys.stderr.flush()
  sys.stdout.write('stdout ')
  sys.stdout.flush()
  time.sleep(0.25)

Config file:

[supervisord]
nodaemon = true

[inet_http_server]
port = 127.0.0.1:9001

[supervisorctl]
serverurl = http://127.0.0.1:9001

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

[program:print]
command = python3 print.py
startsecs = 0
autorestart = false

Start supervisord in the foreground with that config:

$ supervisord --version 
4.0.3

$ supervisord -n -c supervisord.conf 
2019-06-12 18:26:18,620 INFO Increased RLIMIT_NOFILE limit to 1024
2019-06-12 18:26:18,635 INFO RPC interface 'supervisor' initialized
2019-06-12 18:26:18,635 CRIT Server 'inet_http_server' running without any HTTP authentication checking
2019-06-12 18:26:18,635 INFO supervisord started with pid 1676
2019-06-12 18:26:19,643 INFO spawned: 'print' with pid 1679
2019-06-12 18:26:19,692 INFO success: print entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)

In another terminal:

$ supervisorctl -c supervisord.conf
print                            RUNNING   pid 1739, uptime 0:00:19

supervisor> tail print
stdout stdout stdout stdout stdout stdout stdout stdout stdout 

supervisor> tail -f print 
==> Press Ctrl-C to exit <==
stdout stdout stdout stdout stdout stdout stdout stdout stdout ^C

supervisor> tail print stdout
stderr stderr stderr stderr stderr stderr stderr stderr stderr 

supervisor> tail -f print stdout
==> Press Ctrl-C to exit <==
stdout stdout stdout stdout stdout stdout stdout stdout stdout ^C

supervisor> tail print stderr
stderr stderr stderr stderr stderr stderr stderr stderr stderr  

supervisor> tail -f print stderr
==> Press Ctrl-C to exit <==
stderr stderr stderr stderr stderr stderr stderr stderr stderr ^C 

Confirmed the bug (see tail print stdout above). It affects tail but not tail -f. The tail code hasn't changed in a very long time. This bug has probably existed for many Supervisor versions.

I'll test your patch and merge it for the next release. Thanks!

mnaberez added a commit that referenced this pull request Jun 16, 2019

@mnaberez mnaberez merged commit d2ad324 into Supervisor:master Jun 16, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.