supervisor 安装

supervisor

install

1.pip2 安装

wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
tar -xf pip-9.0.1.tar.gz
cd pip-9.0.1
sudo python2 setup.py install

pip2 -V

2.supervisor 安装

sudo pip2 install supervisor

3.创建配置文件

echo_supervisord_conf > /etc/supervisord.conf

  • root权限
  • 报错:
root@iZ2zebwilv3xfcyr58ekbaZ:/home/txn/zgc/pip-9.0.1# sudo echo_supervisord_conf > /etc/supervisord.conf
Traceback (most recent call last):
  File "/usr/local/bin/echo_supervisord_conf", line 7, in <module>
    from supervisor.confecho import main
ImportError: No module named 'supervisor'
  • sudo pip2 uninstall supervisor 卸载重新安装
  • sudo pip2 install supervisor
  • 失败:
root@iZ2zebwilv3xfcyr58ekbaZ:/home/txn/zgc/pip-9.0.1# sudo pip2 install supervisor
Collecting supervisor
Requirement already satisfied: meld3>=0.6.5 in /usr/local/lib/python2.7/dist-packages (from supervisor)
Installing collected packages: supervisor
Successfully installed supervisor-3.3.5
You are using pip version 9.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root@iZ2zebwilv3xfcyr58ekbaZ:/home/txn/zgc/pip-9.0.1# echo_supervisord_conf > /etc/supervisord.conf

4.增加配置文件

  • 添加

sudo vim /etc/supervisord.conf

[include]
files = /etc/supervisor/conf.d/*.conf
  • 路径创建,创建文件

sudo mkdir -p /etc/supervisor/conf.d/

5.增加配置文件(程序)

sudo vim /etc/supervisor/conf.d/mod_demo.conf

  • 输入
[program:mod_demo]
directory = /opt/model_for_demo
command = /usr/bin/python3 grpc_server.py
autostart = true
startsecs = 10
autorestart = true
startretries = 3
user = root
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 5
stdout_logfile = /var/log/supervisor/mod_demo.log
environment=LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/cuda-9.0/lib64:

  • 注: 程序运行失败时,提示缺少环境变量,使用environment 配置

  • 创建log路径

    sudo mkdir -p /var/log/supervisor

6.运行

sudo supervisord -c /etc/supervisord.conf

sudo supervisorctl reload

sudo supervisorctl status

查看运行进程

ps -ef | grep python

7.验证

  • kill pid
  • 等待1秒钟,查看是否进程被启动了

注:

posted on 2018-12-28 18:09  小菜鸟!!  阅读(731)  评论(0编辑  收藏  举报

导航