折腾:
【已解决】CentOS中用supervisor去管理gunicorn的Flask的app
期间,在CentOS中,参考别人帖子,去用pip去安装gunicorn
<code>[root@naturling-general-01 robotDemo]# pip install supervisor Collecting supervisor Downloading http://mirrors.aliyun.com/pypi/packages/44/60/698e54b4a4a9b956b2d709b4b7b676119c833d811d53ee2500f1b5e96dc3/supervisor-3.3.4.tar.gz (419kB) 100% |████████████████████████████████| 419kB 65.9MB/s 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.4.5 (default, Dec 11 2017, 14:22:24) [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-build-8g1wpt6y/supervisor/ You are using pip version 9.0.3, however version 10.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. [root@naturling-general-01 robotDemo]# pip install --upgrade pip Collecting pip Downloading http://mirrors.aliyun.com/pypi/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 80.7MB/s Installing collected packages: pip Found existing installation: pip 9.0.3 Uninstalling pip-9.0.3: Successfully uninstalled pip-9.0.3 Successfully installed pip-10.0.1 [root@naturling-general-01 robotDemo]# pip install supervisor Looking in indexes: http://mirrors.aliyun.com/pypi/simple/ Collecting supervisor Downloading http://mirrors.aliyun.com/pypi/packages/44/60/698e54b4a4a9b956b2d709b4b7b676119c833d811d53ee2500f1b5e96dc3/supervisor-3.3.4.tar.gz (419kB) 100% |████████████████████████████████| 419kB 64.9MB/s 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.4.5 (default, Dec 11 2017, 14:22:24) [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-b6ip5oth/supervisor/ [root@naturling-general-01 robotDemo]# which pip -bash: alias: write error: Success /usr/bin/pip [root@naturling-general-01 robotDemo]# where pip -bash: where: command not found [root@naturling-general-01 robotDemo]# pip --version pip 10.0.1 from /usr/lib/python3.4/site-packages/pip (python 3.4) [root@naturling-general-01 robotDemo]# pip pip pip2 pip2.7 pip3 pip3.4 pipenv pipenv-resolver [root@naturling-general-01 robotDemo]# pip^C [root@naturling-general-01 robotDemo]# pip2 install supervisor Collecting supervisor Downloading http://mirrors.aliyun.com/pypi/packages/44/60/698e54b4a4a9b956b2d709b4b7b676119c833d811d53ee2500f1b5e96dc3/supervisor-3.3.4.tar.gz (419kB) 100% |████████████████████████████████| 419kB 90.5MB/s Collecting meld3>=0.6.5 (from supervisor) Downloading http://mirrors.aliyun.com/pypi/packages/b6/ae/e6d731e4b9661642c1b20591d8054855bb5b8281cbfa18f561c2edd783f7/meld3-1.0.2-py2.py3-none-any.whl Installing collected packages: meld3, supervisor Running setup.py install for supervisor ... done Successfully installed meld3-1.0.2 supervisor-3.3.4 You are using pip version 9.0.1, however version 10.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. [root@naturling-general-01 robotDemo]# pip2 install --upgrade pip2 Collecting pip2 Could not find a version that satisfies the requirement pip2 (from versions: ) No matching distribution found for pip2 You are using pip version 9.0.1, however version 10.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. [root@naturling-general-01 robotDemo]# pip2 install --upgrade pip Collecting pip Downloading http://mirrors.aliyun.com/pypi/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 93.3MB/s Installing collected packages: pip Found existing installation: pip 9.0.1 Uninstalling pip-9.0.1: Successfully uninstalled pip-9.0.1 Successfully installed pip-10.0.1 </code>
期间可见:
默认的pip竟然是python3的
也是醉了。
懒得去解决了。
直接用pip2去安装supervisor
因为supervisor不支持python3
<code>[root@naturling-general-01 robotDemo]# ll /etc/su subgid subuid sudo.conf sudoers sudoers.d/ sudo-ldap.conf [root@naturling-general-01 robotDemo]# ll /etc/sup </code>
可见,此处
/etc/下面并没有我们要的supervisor的配置
难道是应该在CentOS中用
yum install supervisor
才会在/etc/下面有配置?
去看看环境变量中是否包含了:echo_supervisord_conf
是有的:
<code>[root@naturling-general-01 robotDemo]# which echo_supervisord_conf -bash: alias: write error: Success /usr/bin/echo_supervisord_conf </code>
not found /etc/supervisor
not supervisord.conf
Configuration File — Supervisor 3.3.4 documentation
默认会去:
“1. $CWD/supervisord.conf
2. $CWD/etc/supervisord.conf
3. /etc/supervisord.conf
4. /etc/supervisor/supervisord.conf (since Supervisor 3.3.0)
5. ../etc/supervisord.conf (Relative to the executable)
6. ../supervisord.conf (Relative to the executable)”
找
python – supervisor.conf default location – Stack Overflow
“You may have installed supervisor via pip and therefore have the unpatched version in
/usr/local/lib/python2.7/dist-packages/supervisor/“
所以去看看:
<code># ll /usr/local/lib/pytho^C </code>
也没有
所以去:
<code>[root@naturling-general-01 robotDemo]# pip2 uninstall supervisor Uninstalling supervisor-3.3.4: Would remove: /usr/bin/echo_supervisord_conf /usr/bin/pidproxy /usr/bin/supervisorctl /usr/bin/supervisord /usr/lib/python2.7/site-packages/supervisor-3.3.4-py2.7-nspkg.pth /usr/lib/python2.7/site-packages/supervisor-3.3.4-py2.7.egg-info /usr/lib/python2.7/site-packages/supervisor/childutils.py /usr/lib/python2.7/site-packages/supervisor/confecho.py /usr/lib/python2.7/site-packages/supervisor/datatypes.py /usr/lib/python2.7/site-packages/supervisor/dispatchers.py /usr/lib/python2.7/site-packages/supervisor/events.py /usr/lib/python2.7/site-packages/supervisor/http.py /usr/lib/python2.7/site-packages/supervisor/http_client.py /usr/lib/python2.7/site-packages/supervisor/loggers.py /usr/lib/python2.7/site-packages/supervisor/medusa/* /usr/lib/python2.7/site-packages/supervisor/options.py /usr/lib/python2.7/site-packages/supervisor/pidproxy.py /usr/lib/python2.7/site-packages/supervisor/poller.py /usr/lib/python2.7/site-packages/supervisor/process.py /usr/lib/python2.7/site-packages/supervisor/rpcinterface.py /usr/lib/python2.7/site-packages/supervisor/scripts/loop_eventgen.py /usr/lib/python2.7/site-packages/supervisor/scripts/loop_listener.py /usr/lib/python2.7/site-packages/supervisor/scripts/sample_commevent.py /usr/lib/python2.7/site-packages/supervisor/scripts/sample_eventlistener.py /usr/lib/python2.7/site-packages/supervisor/scripts/sample_exiting_eventlistener.py /usr/lib/python2.7/site-packages/supervisor/skel/sample.conf /usr/lib/python2.7/site-packages/supervisor/socket_manager.py /usr/lib/python2.7/site-packages/supervisor/states.py /usr/lib/python2.7/site-packages/supervisor/supervisorctl.py /usr/lib/python2.7/site-packages/supervisor/supervisord.py /usr/lib/python2.7/site-packages/supervisor/tests/* /usr/lib/python2.7/site-packages/supervisor/ui/images/button_refresh.gif /usr/lib/python2.7/site-packages/supervisor/ui/images/button_restart.gif /usr/lib/python2.7/site-packages/supervisor/ui/images/button_stop.gif /usr/lib/python2.7/site-packages/supervisor/ui/images/icon.png /usr/lib/python2.7/site-packages/supervisor/ui/images/rule.gif /usr/lib/python2.7/site-packages/supervisor/ui/images/state0.gif /usr/lib/python2.7/site-packages/supervisor/ui/images/state1.gif /usr/lib/python2.7/site-packages/supervisor/ui/images/state2.gif /usr/lib/python2.7/site-packages/supervisor/ui/images/state3.gif /usr/lib/python2.7/site-packages/supervisor/ui/images/supervisor.gif /usr/lib/python2.7/site-packages/supervisor/ui/status.html /usr/lib/python2.7/site-packages/supervisor/ui/stylesheets/supervisor.css /usr/lib/python2.7/site-packages/supervisor/ui/tail.html /usr/lib/python2.7/site-packages/supervisor/version.txt /usr/lib/python2.7/site-packages/supervisor/web.py /usr/lib/python2.7/site-packages/supervisor/xmlrpc.py Proceed (y/n)? y Successfully uninstalled supervisor-3.3.4 </code>
原来是放在了:
/usr/lib/python2.7/site-packages/supervisor/
中了。
不是我们希望的。
所以换成CentOS中的yum去安装:
<code>[root@naturling-general-01 robotDemo]# echo_supervisord_conf ^C [root@naturling-general-01 robotDemo]# which echo_supervisord_conf -bash: alias: write error: Success /usr/bin/echo_supervisord_conf [root@naturling-general-01 robotDemo]# which supervisor -bash: alias: write error: Success /usr/bin/which: no supervisor in (/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin) [root@naturling-general-01 robotDemo]# which supervisord -bash: alias: write error: Success /usr/bin/supervisord [root@naturling-general-01 robotDemo]# which supervisorctl -bash: alias: write error: Success /usr/bin/supervisorctl [root@naturling-general-01 robotDemo]# ll /etc/supervisord.* -rw-r--r-- 1 root root 7953 Jul 29 2017 /etc/supervisord.conf /etc/supervisord.d: total 0 [root@naturling-general-01 robotDemo]# ll /etc/supervisord* -rw-r--r-- 1 root root 7953 Jul 29 2017 /etc/supervisord.conf /etc/supervisord.d: total 0 [root@naturling-general-01 robotDemo]# ll /etc/supervisord. supervisord.conf supervisord.d/ [root@naturling-general-01 robotDemo]# ll /etc/supervisord.d/ total 0 [root@naturling-general-01 robotDemo]# </code>
就安装了,其能找到:
echo_supervisord_conf
/etc/supervisord.conf
/etc/supervisord.d/
了。
【总结】
对于CentOS这类系统,如果用pip去安装的supervisor的话,则默认supervisor会被安装到python所在目录,比如此处的:
<code>pip2 install supervisor </code>
结果supervisor会被安装到,当前python2下:
/usr/lib/python2.7/site-packages/supervisor/
所以,在:
/etc/
下找不到:
supervisord.conf
解决办法是:
用pip去卸载掉:
<code>pip uninstall supervisor pip2 uninstall supervisor </code>
重新用包管理器去安装
CentOS:yum install supervisord
Ubuntu:apt-get install supervisord
即可看到:
/etc/supervisord.conf
/etc/supervisord.d/
转载请注明:在路上 » 【已解决】CentOS中用python2的pip去安装supervisor后找不到/etc/supervisor中的默认配置文件supervisord.conf