推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
sevenandeleven
V2EX  ›  Python

Python Bottle 框架遇到的问题,求解

  •  
  •   sevenandeleven · Nov 15, 2022 · 3103 views
    This topic created in 1451 days ago, the information mentioned may be changed or developed.

    用 Python 的轻量级 bottle 框架搭了一个 web 服务,使用 docker 容器运行,但是会出现间断性的 502 错误,有时候十天半个月,有时候隔两天就会出现,必须得重启 docker 容器之后才能正常访问接口,请问这是什么原因导致的?

    6 replies  •  2022-11-17 17:23:14 +08:00
    bonfy
    bonfy
    Nov 15, 2022
    1
    你不发 log 咋知道?

    估计代码逻辑有问题,哪里出错就挂了

    然后部署也是 直接 `python xxxx.py` 这样跑的,没有用 一些 gunicorn 之类的服务吧?
    sevenandeleven
    sevenandeleven
    OP
    Nov 15, 2022
    2
    @bonfy log 有的,所有接口都加了的,但是一条错误日志也没有,确实没有用 gunicorn 之类的服务,这个会有影响吗
    bonfy
    bonfy
    Nov 15, 2022
    3
    肯定有啊

    支持多线程有的多进程,至少挂了一个其它的还在跑啊,能让你的服务活得长些

    而且 应该还有支持 服务挂了 自动重启的吧

    你去看看各个服务的文档吧
    ClericPy
    ClericPy
    Nov 15, 2022 via Android
    4
    bottle 见过运行 2 年不挂的,基本可以排除它,源码那么干净一看就明白了

    502 不产生日志这日志还有什么用.... 如果 504 还能怀疑一下是主线程被强 CPU 占用或者其它方式堵了,502 基本就是流量没通到逻辑层,以前遇到多数是 nginx 收到流量但是 service 没收到,去 nginx 日志看看请求啥了
    julyclyde
    julyclyde
    Nov 15, 2022
    5
    直接运行,你这个程序应该只能服务一个连接吧
    DrLty
    DrLty
    Nov 17, 2022
    6
    直接全加上 try
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4639 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 01:15 · PVG 09:15 · LAX 17:15 · JFK 20:15
    ♥ Do have faith in what you're doing.