python 3使用supervisor做守护进程

楚天乐 1622 0 条

问题

centos 7系统,python 3.6环境下用pip install supervisor会报错, 简单说就是supervisor不支持python 3

[root@li999-188 python-supervisor]# pip3 install supervisor
Collecting supervisor
  Using cached https://files.pythonhosted.org/packages/44/60/698e54b4a4a9b956b2d709b4b7b676119c833d811d53ee2500f1b5e96dc3/supervisor-3.3.4.tar.gz
    Complete output from command python setup.py egg_info:
    Supervisor requires Python 2.4 or later but does not work on any version of Python 3.  You are using version 3.6.6 (default, Aug  6 2018, 01:04:23)
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)].  Please install using a supported version.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-qxpt_hch/supervisor/

解决方案

CentOS 7自带python2.7,而我升级python之后,系统里是有3.6和2.7两个版本的python的。
那么,我们用python2.7安装supervisor,安装成功

[root@li999-188 bin]# pip install supervisor
Collecting supervisor
  Using cached https://files.pythonhosted.org/packages/44/60/698e54b4a4a9b956b2d709b4b7b676119c833d811d53ee2500f1b5e96dc3/supervisor-3.3.4.tar.gz
Requirement already satisfied: meld3>=0.6.5 in /usr/lib/python2.7/site-packages (from supervisor) (1.0.2)
Installing collected packages: supervisor
  Running setup.py install for supervisor ... done
Successfully installed supervisor-3.3.4

建立supervisor配置文件

echo_supervisord_conf > /home/python-supervisor/supervisord.conf

打开配置文件,增加如下配置

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

[program:项目名称]
directory = /home/wwwroot/项目目录
command = gunicorn 项目名称.wsgi:application -b 127.0.0.1:8000 --reload

shell命令启动项目

supervisord -c /home/python-supervisor/supervisord.conf

加入系统自启动列表
vim /etc/rc.d/rc.local

增加如下代码

supervisord -c /home/python-supervisor/supervisord.conf


发表我的评论
'
昵称 (必填)
邮箱 (必填)
网址