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

error: <class 'xml.parsers.expat.ExpatError'>, unclosed token: line 130, column 0: file: /usr/lib/python3.10/xmlrpc/client.py line: 460 #1623

Open
yangyile1990 opened this issue Jan 25, 2024 · 1 comment

Comments

@yangyile1990
Copy link

yangyile1990 commented Jan 25, 2024

supervisor> 
supervisor> restart simple:
error: <class 'xml.parsers.expat.ExpatError'>, unclosed token: line 130, column 0: file: /usr/lib/python3.10/xmlrpc/client.py line: 460
supervisor> 

Now all the sub service in the simple: group are STOPPED

Then run the same commond. get the same error message.

supervisor> 
supervisor> restart simple:
error: <class 'xml.parsers.expat.ExpatError'>, unclosed token: line 130, column 0: file: /usr/lib/python3.10/xmlrpc/client.py line: 460
supervisor> 

Now all the sub service in the simple: group are RUNNING

supervisor> 
supervisor> version
4.2.1
supervisor> 

So what is the reason.

I can restart my sub service one by one.

By the way my simple.conf contains a lot of chinese characters. I think this is the reason. But I have to use chinese characters as my project is chinese and my project path is chinese an my log path is in chinese.

So how to support NON-ASCII code in conf file? If you don't support use chinese characters in the conf file, you can also tell it to me. As I have read the doc but I can not find it says not support chinese characters.

please help me.

@waketzheng
Copy link

After try a demo, I found that supervisor did support non-ascii characters in conf file.

Example

  • dongfang.conf
[program:dongfang]
command=poetry run fastapi run --workers=3 --port=9527
user=root
directory=/root/部署/%(program_name)s
stdout_logfile=/root/部署/%(program_name)s/supervisor.log

numprocs=1
autostart=true
startsecs=10
autorestart=true
startretried=3
redirect_stderr=true
stdout_logfile_maxbytes=20MB
stdout_logfile_backups=20
  • main.py
#!/usr/bin/env python
from pathlib import Path

import fastapi_cdn_host
import uvicorn
from fastapi import FastAPI

BASE_DIR = Path(__file__).resolve().parent
app = FastAPI(title=BASE_DIR.name)
fastapi_cdn_host.patch_docs(app)


@app.get('/')
async def root():
    return '车如流水马如龙,美人如玉剑如虹。'


def main() -> None:
    uvicorn.run(f'{Path(__file__).stem}:app', reload=True)


if __name__ == '__main__':
    main()
  • pyproject.toml
[tool.poetry]
name = "dongfang"
version = "0.1.0"
description = ""
authors = []
readme = "README.md"
package-mode = false

[tool.poetry.dependencies]
python = "^3.11"
fastapi = "^0.112.2"
uvicorn = "^0.30.6"
fastapi-cdn-host = "^0.7.5"
fastapi-cli = {version = "^0.0.5", platform = "linux"}


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
  • Install poetry and deps
pip install pipx --user
which pipx || export PATH=$PATH:$HOME/.local/bin
pipx ensurepath
pipx install poetry
wget https://mirror.ghproxy.com/https://raw.githubusercontent.com/waketzheng/carstino/main/pip_conf.py
python pip_conf.py --poetry # 给poetry换源
mkdir /root/部署
cd /root/部署
poetry new dongfang
cd dongfang
poetry add fastapi uvicorn fastapi-cdn-host fastapi-cli
[[ -f man.py ]] || echo -e "from fastapi import FastAPI\napp=FastAPI()\[email protected]('/')\nasync def root():\n    return 'homepage'" > main.py
poetry run fastapi dev main.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants