Supervisor安装、配置、开启启动

时间:2023-12-21 16:11:08

1、安装Python包管理工具(easy_install)
  wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py -O - | sudo python

2、安装supervisor
  easy_install supervisor

2.1、查看版本,检验是否安装成功
  supervisord -v

3、配置
3.1、生成supervisor的初始化配置文件
  echo_supervisord_conf > /etc/supervisord.conf

3.2、编辑supervisord.conf
  vim /etc/supervisord.conf

3.3、配置启动内容
  [program:mobileyingfeng]
  command=/usr/bin/java -Djava.security.egd=file:/dev/./urandom -Dserver.port=85 -Dspring.profiles.active=prod -Dspring.datasource.password=2S323uHHH -Dspring.redis.password=K6EnRBjLa -jar /root/yingfeng/mobileyingfeng.jar
  user=root
  stderr_logfile = /root/yingfeng/logs/mobile-yingfeng-error.log
  stdout_logfile = /root/yingfeng/logs/mobile-yingfeng.log
  directory=/
3.4、在下图位置添加添加上面的内容
  Supervisor安装、配置、开启启动

3.5、手动启动:
  supervisord -c /etc/supervisord.conf

3.6、相关命令:
  supervisorctl update 重新加载配置
  supervisorctl reload 重新启动所有程序
  supervisorctl status 查看状态

4、开机启动
  vim /usr/lib/systemd/system/supervisord.service

4.1、supervisord.service文件内容:

  # dservice for systemd (CentOS 7.0+)
  # by ET-CS (https://github.com/ET-CS)
  [Unit]
  Description=Supervisor daemon
  [Service]
  Type=forking
  ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
  ExecStop=/usr/bin/supervisorctl shutdown
  ExecReload=/usr/bin/supervisorctl reload
  KillMode=process
  Restart=on-failure
  RestartSec=42s
  [Install]
  WantedBy=multi-user.target

4.2、设为开机启动
  systemctl enable supervisord

4.3、验证一下是否为开机启动
  systemctl is-enabled supervisord