supervisor 是由python语言编写、基于linux操作系统的一款服务器管理工具,用以监控服务器的运行,发现问题能立即自动预警及自动重启等功能。
1.首先必须先安装好python环境,linux已经自带python,建议安装python2.7.5.先在终端输入python查看python版本,能正常显示则表明没问题,输入exit()退出python环境。
root@debian-lege-pro:~# python Python 2.7.3 (default, Mar 13 2014, 11:03:55) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
2.在终端输入 easy_install supervisor 并回车,linux会自动联网并下载supervisor源码解压并安装。
root@debian-lege-pro:~# easy_install supervisor Searching for supervisor Reading http://pypi.python.org/simple/supervisor/ Best match: supervisor 3.1.3 Downloading https://pypi.python.org/packages/source/s/supervisor/supervisor-3.1.3.tar.gz#md5=aad263c4fbc070de63dd354864d5e552 Processing supervisor-3.1.3.tar.gz Running supervisor-3.1.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-wvBP8U/supervisor-3.1.3/egg-dist-tmp-K8ZYGt warning: no previously-included files matching '*' found under directory 'docs/.build' Adding supervisor 3.1.3 to easy-install.pth file Installing echo_supervisord_conf script to /usr/local/bin Installing pidproxy script to /usr/local/bin Installing supervisorctl script to /usr/local/bin Installing supervisord script to /usr/local/bin Installed /usr/local/lib/python2.7/dist-packages/supervisor-3.1.3-py2.7.egg Processing dependencies for supervisor Searching for meld3>=0.6.5 Reading http://pypi.python.org/simple/meld3/ Best match: meld3 1.0.0 Downloading https://pypi.python.org/packages/source/m/meld3/meld3-1.0.0.tar.gz#md5=ca270506dd4ecb20ae26fa72fbd9b0be Processing meld3-1.0.0.tar.gz Running meld3-1.0.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-j6B46f/meld3-1.0.0/egg-dist-tmp-7Yahmi zip_safe flag not set; analyzing archive contents... Adding meld3 1.0.0 to easy-install.pth file Installed /usr/local/lib/python2.7/dist-packages/meld3-1.0.0-py2.7.egg Finished processing dependencies for supervisor
3.安装成功后显示finished,我们再次进行python环境,输入import supervisor ,如果没提示错误则表示安装成功。
root@debian-lege-pro:~# python Python 2.7.3 (default, Mar 13 2014, 11:03:55) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import supervisor >>>
4.接下来是对supervisor配置,首先我们要生成配置文件,在shell终端输入 echosupervisordconf > /etc/supervisord.conf
root@debian-lege-pro:~# echo_supervisord_conf > /etc/supervisord.conf
5.接着编辑配置文件 vim /etc/supervisord.conf 在最底部添加如下参数 [program:app] command=python /usr/local/app/web/app.py autorstart=true stdout_logfile=/tmp/hello.log 编辑完成后保存退出
root@debian-lege-pro:~# vim /etc/supervisord.conf .... [program:app] command=python /usr/local/app/web/app.py autorstart=true stdout_logfile=/tmp/hello.log
6.ps命令查看运行情况,应用现在已经自动运行了。
root@debian-lege-pro:~# ps -ef | grep super root 12 2 0 03:15 ?00:00:00 [sync_supers] root 3625 3138 0 04:40 pts/000:00:00 grep super
来源:https://www.cnblogs.com/lege/p/4224538.html