Supervisor安裝、配置、開啟啟動

騎車走西藏發表於2018-04-10

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、在下圖位置新增新增上面的內容
  

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

相關文章