推荐学习书目
› 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
jianlu
V2EX  ›  Python

问一下, uwsgi 启动 Python 服务,怎么启动带配置文件目录的 Python 项目?

  •  
  •   jianlu · Jan 25, 2018 · 5229 views
    This topic created in 3169 days ago, the information mentioned may be changed or developed.
    我现在有一个 python 服务
    启动命令是:'python3 main.py -p 8080 -c conf_testenv'
    如果换成 uwsgi 启动,那这个'-c conf_testenv'怎么写在 uwsgi 的命令里?
    '/usr/bin/uwsgi --http :8080 --wsgi-file main.py --callable App --master --processes 4 --threads 8'
    求解
    7 replies  •  2018-01-25 18:33:13 +08:00
    julyclyde
        1
    julyclyde  
       Jan 25, 2018
    这取决于
    main.py 怎么理解-c 参数
    jianlu
        2
    jianlu  
    OP
       Jan 25, 2018
    @julyclyde -c 是通过 argparse 的 add_argument 自动添加的
    wellsc
        3
    wellsc  
       Jan 25, 2018
    可以考虑将一部分配置文件写到环境变量里面
    julyclyde
        4
    julyclyde  
       Jan 25, 2018
    @jianlu 那你这种用法不对,你的 main.py 里,包含了“不只是 wsgi app “的 argparse 这部分功能
    而 uwsgi 期望你给它的是一个 wsgi app
    azhi
        5
    azhi  
       Jan 25, 2018
    sudo ln -s /path/to/your/mysite/mysite_uwsgi.ini /etc/uwsgi/vassals/
    #把下边这句增加到 /etc/rc.local 即可自动读取配置文件,且开机启动
    /usr/local/python3/bin/uwsgi --emperor /etc/uwsgi/vassals
    FindHao
        6
    FindHao  
       Jan 25, 2018 via Android
    FindHao
        7
    FindHao  
       Jan 25, 2018 via Android
    比如你是 flask,自带有添加 run cmd 的管理库。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2502 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 15:48 · PVG 23:48 · LAX 08:48 · JFK 11:48
    ♥ Do have faith in what you're doing.