python项目部署之uwsgi配置说明

uwsgi配置

  1. 在项目文件夹同级目录创建logs文件夹,创建log、pid、sock文件
    例:~/project/foodtop
    mkdir logs
    cd logs
    touch foodtop.log foodtop.pid foodtop.sock
  1. 在项目文件夹同级目录创建文件uwsgi.ini
    在uwsgi.ini文件中加入如下内容:
    注意:①其中目录必须是绝对路径
    ②必须在开头加上[uwsgi],否则无法识别
    ③配置项中的文件必须先创建,否则在云心uwsgi服务器时会报错
    [uwsgi]
    #源码目录
    chdir=/home/shoupt/project/foodtop
    #python虚拟环境
    home=/home/shoupt/env/foodtop
    #模块文件名
    module=manage
    #模块中的应用对象
    callable=app
    master=true
    #进程数
    process=4
    #地址
    http=0.0.0.0:8080
    #sock文件目录
    socket=/home/shoupt/project/logs/foodtop.sock
    #缓存区大小
    buffer-size=3072
    #pid文件目录
    pidfile=/home/shoupt/project/logs/foodtop.pid
    #权限设置
    chmod-socket=777
    logfile-chmod=644
    #log文件目录
    daemonize=/home/shoupt/project/logs/foodtop.log
    #静态文件映射
    static-map = /static=/home/shoupt/project/foodtop/web/static

3.进入到uwsgi.ini所在目录,运行如下命令:
1)多进程启动服务:

uwsgi --ini uwsgi.ini

2)跟踪log记录:

tail -f 

3)停止服务器:

 uwsgi --stop 

4)重载服务器:

 uwsgi --reload 

你可能感兴趣的:(后端,运维)