学习supervisor

supervisor是python写的进程管理工具

安装

因为是python写的,所以可以用pip安装。

sudo apt-get install supervisor
pip install supervisor

结构

服务器端

  • 服务端配置文件默认位置
sudo vim /etc/supervisor/supervisord.conf
  • 导出配置文件
echo_supervisord_conf > /etc/supervisor/supervisord.conf
  • 启动命令
supervisord -c /etc/supervisor/supervisord.conf

客户端

  • 命令行客户端supervisorctl
    需要在配置文件中添加
[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700
  • web客户端
    需要在配置文件中添加
[inet_http_server]
port=*:30040
username=admin
password=admin

自动启动

/etc/rc.local中增加一行

service supervisor start 

配置文件

  • 监控对象服务的配置文件
    默认位置存放于/etc/supervisor/conf.d/*.conf。建议将程序的配置文件放置到各自项目文件夹下,然后将配置文件用硬链接放到默认文件夹下。

  • 默认日志文件

tail -f /var/log/supervisord.log
  • Supervisor重新加载配置启动新的进程
    参考文章

你可能感兴趣的:(学习supervisor)