Supervisor / supervisor

Supervisor process control system for Unix (supervisord)
http://supervisord.org
Other
8.33k stars 1.23k forks source link

Bug: supervisorctl thorws error when doing tail on logs with control characters in them. #1611

Closed pete312 closed 7 months ago

pete312 commented 7 months ago

This is a reproducible error with code below. Getting this error which I isolated down to a ctrl char in the output.

supervisor> tail test error: <class 'xml.parsers.expat.ExpatError'>, not well-formed (invalid token): line 5, column 36: file: /usr/lib64/python3.9/xmlrpc/client.py line: 451

python: Python 3.9.16 supervisor==4.2.5

supervisor.conf file
[unix_http_server]
file=/home/devop/var/run/supervisor.http.sock   ; (the path to the socket file)
#chmod=0770        ; socket file mode (default 0700)

[supervisord]
logfile=/home/devop/var/log/supervisord.log  ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10          ; (num of main logfile rotation backups;default 10)
loglevel=info               ; (log level;default info; others: debug,warn,trace)
pidfile=/home/devop/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false              ; (start in foreground if true;default false)
minfds=1024                 ; (min. avail startup file descriptors;default 1024)
minprocs=200                ; (min. avail process descriptors;default 200)

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

[supervisorctl]
serverurl=unix:///home/devop/var/run/supervisor.http.sock ; use a unix:// URL  for a unix socket

[include]
files = /home/devop/conf.d/*.conf

file mode on sock srwx------ 1 sx sx 0 Nov 16 11:03 /home/devop/var/run/supervisor.http.sock

kernal : 5.14.0-284.25.1.0.1.el9_2.x86_64 oracle linux 8

conf file of app.

[program:test]
command=%(ENV_HOME)s/testsupervisor.py
stdout_logfile=%(ENV_HOME)s/var/log/testsupervisor.log
environment=PYTHONUNBUFFERED=true
redirect_stderr=true

testsupervisor.py simply overwrites the last line in stdout.

#!/usr/bin/env python3

import time
from datetime import datetime as dt

cl_deleol= "\033[K"   # delete line
cl_reset='\033[0m'   # reset color
cl_moveup= "\033[1A"  # move cursor one line up

def overwrite(s):
    return cl_moveup + cl_deleol + str(s) + cl_reset

while 1:
    print(overwrite(f"testsupervisor {dt.now().strftime('%H:%M:%S')}"))
    #print(f"testsupervisor {dt.now().strftime('%H:%M:%S')}")
    time.sleep(1)

Running this test script will cause the tail test to fail. The use case for this is to show a last timestamp on stdout msgs that have no timestamp withtout littering the screen with no activity timestamps. Interestingly a tail -f test works fine.

mnaberez commented 7 months ago

Duplicate of #85