部署到服务上

1.在主目录中添加一个wsgi.py文件python

# -*- coding:utf-8 -*-
import sys
from os.path import abspath
from os.path import dirname

sys.path.insert(0, abspath(dirname(__file__)))

import app

# 必须有一个叫作application的变量
# gunicorn 就要这个变量
# 这个变量的值必须是Flask的实力
application = app.app

# 这是把代码部署到 apache gunicorn nginx 后面的套路

2.安装gunicorn    pip3 install gunicorn (green unicorn) 独角兽nginx

3. gunicorn wsgi --bind 0.0.0.0:2000apache

4.安装supervisor :    pip install supervisor app

5. 把/usr/local/lib/python2.7/dist-packages/supervisor移动到/etc/supervisorpython2.7

6.生成配置文件 echo_supervisord_conf > /etc/supervisor/supervisord.confspa

7.建立/etc/supervisor/conf.d目录,用于存放进程管理文件blog

8.修改/etc/supervisor/supervisord.conf中的最后的[include]参数, 将/etc/supervisor/conf.d目录添加到include中进程

9.在conf.d下建立一todo.ini的文件ip

  1 [progarm:todo]
  2 command=gunicorn --bind 0.0.0.0:2000 --pid/tem/todo.pid
  3 directory=/root/home/python/Desktop/day13
  4 autosatrt=ture
~                    

10. supervisorctl start todoutf-8

相关文章
相关标签/搜索