tiagocoutinho/multivisor

rpc.py, line 117, ValueError if string is not standard

Opened this issue · 3 comments

In the rpc.py, line 117, parsing error if a string is not standard, like this:
processname:websocket_vosk groupname:websocket_vosk pid:14 channel:stdout DEBUG - 2022-02-16 14:13:03,092 - __main__ - start - Trying to load model at: /opt/vosk-models/vosk-model-small-en-us-0.15 LOG (VoskAPI:ReadDataFiles():model.cc:213) Decoding params beam=10 max-active=3000 lattice-beam=2 LOG (VoskAPI:ReadDataFiles():model.cc:216) Silence phones 1:2:3:4:5:6:7:8:9:10

After splitting it looks like this:
['processname:websocket_vosk', 'groupname:websocket_vosk', 'pid:14', 'channel:stdout', 'LOG', '(VoskAPI:ReadDataFiles():model.cc:213)', 'Decoding', 'params', 'beam=10', 'max-active=3000', 'lattice-beam=2', 'LOG', '(VoskAPI:ReadDataFiles():model.cc:216)', 'Silence', 'phones', '1:2:3:4:5:6:7:8:9:10']


I use multivisor[rpc]

supervisord.conf:
`[rpcinterface:supervisor]
supervisor.rpcinterface_factory = multivisor.rpc:make_rpc_interface

[supervisorctl]
serverurl=%(ENV_SUPERVISOR_SUPERVISORCTL_SERVERURL)s

[rpcinterface:multivisor]
supervisor.rpcinterface_factory = multivisor.rpc:make_rpc_interface
bind=%(ENV_SUPERVISOR_RPCINTERFACE_MULTIVISOR_BIND)s`

Thanks for the report @exactstat.

I assume you're referring to multivisor/rpc.py (cause there's also a multivisor/server/rpc.py)

What do you you mean by "string is not standard"?

Could you send the complete multivisor.conf and supervisor.conf files?

Looks like maybe you've already found a solution. Would you be willing to write a PR with a fix?

Hi, @tiagocoutinho !

Here is my sandbox project with all .conf files required. https://github.com/exactstat/api-sandbox.git (it's public)

Run the docker compose up and look at the std output:

image

I have a fix. I will create a pull request today.

I don't have access to the repo :)
Here is my fix in the multivisor/rpc.py in the _process_event(self, event) method.
I cut all characters after channel:stdout before parsing the payload_str. Because these characters contain logs with an unexpected structure that can't be parsed to a dict and probably should not be parsed.

if "channel:stdout" in payload_str:
            payload_str = payload_str.split("channel:stdout")[0]+"channel:stdout"
payload = dict((x.split(":") for x in payload_str.split()))