19 / 09 / 18

Supervisor为Go守护进程

系统

CentOS7.x

步骤

  1. 切换用户为root
# sudo su - #切换为root用户
  1. 安装
# yum install epel-release
# yum install -y supervisor
# systemctl enable supervisord # 开机自启动
# systemctl start supervisord # 启动supervisord服务

# systemctl status supervisord # 查看supervisord服务状态
# ps -ef|grep supervisord # 查看是否存在supervisord进程
  1. 创建supervisor所需目录
# mkdir /etc/supervisord.d/
  1. 创建supervisor配置文件
# echo_supervisord_conf > /etc/supervisord.conf
  1. 编辑supervisord.conf文件
[include]
files = /etc/supervisord.d/*.ini
  1. 启动supervisor
# supervisord -c /etc/supervisord.conf
  1. 重启ERROR

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

find / -name supervisor.sock
unlink /tmp/supervisor.sock
  1. *.ini 文件模板
[program:server_version]
command=/usr/local/gopath/bin/version_pro
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/var/log/supervisord/version.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/var/log/supervisord/version.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB