supervisor - Python进程管理工具

1.下载

apt-get install supervisor

2.修改配置文件

vim /etc/supervisor/supervisord.conf 

[program:process_node]
command=python /home/x/mt4client/process_node.py -n ss1@127.0.0.1 -c 123456 2>&1 &
autorstart=true
stdout_logfile=/home/x/mt4client/log/process_node.log

3.启动

/etc/init.d/supervisor start

启动的时候遇到错误

Starting supervisor: Unlinking stale socket /var/run/supervisor.sock
Traceback (most recent call last):
  File "/usr/bin/supervisord", line 9, in <module>
    load_entry_point('supervisor==3.0a8', 'console_scripts', 'supervisord')()
  File "/usr/lib/pymodules/python2.7/supervisor/supervisord.py", line 371, in main
    go(options)
  File "/usr/lib/pymodules/python2.7/supervisor/supervisord.py", line 381, in go
    d.main()
  File "/usr/lib/pymodules/python2.7/supervisor/supervisord.py", line 94, in main
    self.run()
  File "/usr/lib/pymodules/python2.7/supervisor/supervisord.py", line 104, in run
    self.options.openhttpservers(self)
  File "/usr/lib/pymodules/python2.7/supervisor/options.py", line 1039, in openhttpservers
    self.httpservers = self.make_http_servers(supervisord)
  File "/usr/lib/pymodules/python2.7/supervisor/options.py", line 1242, in make_http_servers
    return make_http_servers(self, supervisord)
  File "/usr/lib/pymodules/python2.7/supervisor/http.py", line 799, in make_http_servers
    from web import supervisor_ui_handler
  File "/usr/lib/pymodules/python2.7/supervisor/web.py", line 29, in <module>
    import meld3
  File "/usr/lib/pymodules/python2.7/meld3/__init__.py", line 2, in <module>
    from meld3 import parse_xml
  File "/usr/lib/pymodules/python2.7/meld3/meld3.py", line 27, in <module>
    from xml.etree.ElementTree import fixtag
ImportError: cannot import name fixtag

找了下资料要安装

aptitude install python-meld3
pip install meld3==0.6.7

又报错

The program 'aptitude' can be found in the following packages:
 * aptitude
 * aptitude-gtk
Try: apt-get install <selected package>

继续

apt-get install aptitude aptitude-gtk

 

遇到的错误2

 * Starting Supervisor daemon manager...
Error: Another program is already listening on a port that one of our HTTP servers is configured to use.  Shut this program down first before starting supervisord.
For help, use /usr/bin/supervisord -h
   ...fail!

解决办法

find / -name supervisor.sock
unlink /***/supervisor.sock

 

OK 成功程序起来了

sudo supervisorctl status hello     -- 获取hello服务的状态,因为是autorstart,这里已经启动了
hello  RUNNING    pid 1159, uptime 0:20:32

sudo supervisorctl status hello     -- 获取hello服务的状态,因为是autorstart,这里已经启动了
hello  RUNNING    pid 1159, uptime 0:20:32
sudo supervisorctl stop hello       -- 停止hello服务
hello: stopped
sudo supervisorctl stop hello       -- 再次停止hello,会有错误信息
hello: ERROR (not running)
sudo supervisorctl start hello      -- 启动hello服务
hello: started

 

posted @ 2013-03-19 18:30  firesnow  阅读(10157)  评论(0编辑  收藏  举报