supervisor 是由python语言编写、基于linux操作系统的一款服务器管理工具,用以监控服务器的运行,发现问题能立即自动预警及自动重启等功能。
1.首先必须先安装好python环境,linux已经自带python,建议安装python2.7.5.先在终端输入python查看python版本,能正常显示则表明没问题,输入exit()退出python环境。
root@debian-lege-pro:~# pythonPython2.7.3(default, Mar132014,11:03:55) [GCC4.7.2] on linux2Type"help","copyright","credits"or"license"formore information.>>>
2.在终端输入 easy_install supervisor 并回车,linux会自动联网并下载supervisor源码解压并安装。
root@debian-lege-pro:~# easy_install supervisorSearchingforsupervisorReading http://pypi.python.org/simple/supervisor/Best match: supervisor3.1.3Downloading 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 -qbdist_egg --dist-dir /tmp/easy_install-wvBP8U/supervisor-3.1.3/egg-dist-tmp-K8ZYGtwarning:nopreviously-included files matching'*'found under directory'docs/.build'Adding supervisor3.1.3to easy-install.pth fileInstalling echo_supervisord_conf script to /usr/local/binInstalling pidproxy script to /usr/local/binInstalling supervisorctl script to /usr/local/binInstalling supervisord script to /usr/local/binInstalled /usr/local/lib/python2.7/dist-packages/supervisor-3.1.3-py2.7.eggProcessing dependenciesforsupervisorSearchingformeld3>=0.6.5Reading http://pypi.python.org/simple/meld3/Best match: meld31.0.0Downloading https://pypi.python.org/packages/source/m/meld3/meld3-1.0.0.tar.gz#md5=ca270506dd4ecb20ae26fa72fbd9b0beProcessing meld3-1.0.0.tar.gzRunning meld3-1.0.0/setup.py -qbdist_egg --dist-dir /tmp/easy_install-j6B46f/meld3-1.0.0/egg-dist-tmp-7Yahmizip_safe flagnotset; analyzing archive contents...Adding meld31.0.0to easy-install.pth fileInstalled /usr/local/lib/python2.7/dist-packages/meld3-1.0.0-py2.7.eggFinished processing dependenciesforsupervisor
3.安装成功后显示finished,我们再次进行python环境,输入import supervisor ,如果没提示错误则表示安装成功。
root@debian-lege-pro:~# pythonPython2.7.3(default, Mar132014,11:03:55) [GCC4.7.2] on linux2Type"help","copyright","credits"or"license"formore 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.pyautorstart=truestdout_logfile=/tmp/hello.log
6.ps命令查看运行情况,应用现在已经自动运行了。
root@debian-lege-pro:~# ps -ef | grep superroot122003:15?00:00:00[sync_supers]root36253138004:40pts/000:00:00grepsuper