alexsilva / supervisor

Supervisor process control system for Windows
http://supervisord.org
Other
118 stars 26 forks source link

Supervisor win higher version Chinese garbled code #49

Open wssf812 opened 1 year ago

wssf812 commented 1 year ago

Supervisor-win higher version Chinese garbled code,the version used is 4.7.0. Under 4.5.0, there will be no garbled code,Why is this? Error info: дredis{'name': 'Ա', 'user_id': 22}

alexsilva commented 1 year ago

@wssf812 Do you have any configuration examples and how to reproduce this failure? I don't fully understand what problem you are facing.

wssf812 commented 1 year ago

@wssf812 Do you have any configuration examples and how to reproduce this failure? I don't fully understand what problem you are facing.

To reproduce simply add Chinese logs to the backend service This is my configuration file: [inet_http_server] port=127.0.0.1:9001

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

[supervisord] logfile=D:\flexibleline_backend\supervisor\log\supervisord.log pidfile=D:\flexibleline_backend\supervisor\pid\supervisord.pid loglevel=info

[program:flexibleline_api] command=cmd.exe /K "conda activate flex_line_env && cd /d D:\flexibleline_backend && python main.py" autostart=true autorestart=true startretries=3 stdout_logfile=D:\flexibleline_backend\supervisor\log\flexibleline_api_err.log stderr_logfile=D:\flexibleline_backend\supervisor\log\flexibleline_api_err.log

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

The problem I encountered was that there was garbled code when writing Chinese logs in version 4.7.0, but switching to version 4.5.0 was no problem. After checking your source code, I found that the difference between the two was due to the issue with win.WriteFile, where the encoding was not specified.

This is just my speculation, but from the perspective of the issue, it should be a coding exception caused by a higher version of the program. It may be a problem with the window plugin, a bug on your code, or a coding issue itself. I hope you can take a look and give me a response. Thank you

alexsilva commented 1 year ago

The default encoding used is utf8 and this encoding is used to convert any byte to string. The Chinese language may not be able to convert some characters. The default behavior is to ignore such characters so as not to critically fail.

Ouput stream read

wssf812 commented 1 year ago

The default encoding used is utf8 and this encoding is used to convert any byte to string. The Chinese language may not be able to convert some characters. The default behavior is to ignore such characters so as not to critically fail.

Ouput stream read

Why is version 4.5.0 possible? I see that the address code corresponding to version 4.5.0 of the connection you sent is as follows, and there is also an error in ignoring it. I am a bit confused 4.5.0 code: def handle_read_event(self): data = self.process.config.options.readfd(self.fd) if data is not None: # empty queue self.output_buffer += as_bytes(data, ignore=True) self.record_output() if not data:

if we get no data back from the pipe, it means that the

            # child process has ended.  See
            # mail.python.org/pipermail/python-dev/2004-August/046850.html
            self.close()

4.5.0 as_bytes function def as_bytes(s, encoding='utf-8', ignore=False): return _Stream(s, bytes).encode(encoding=encoding, ignore=ignore)

Please refer to the code similar to yours in version 4.5.0 above, which also includes' ignore 'as' true'