部署到服務上

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

相關文章
相關標籤/搜索