ubuntu18.04
安装包下载地址:https://github.com/ochinchina/supervisord/releases/tag/v0.7.3
mkdir -p /etc/supervisord/conf.d
目录中的supervisord二进制文件为上面安装包中的二进制文件
/etc/supervisord/supervisord.conf
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[supervisord]
logfile=/var/log/supervisor/supervisord.log ;(main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ;(supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
logfile_maxbytes=50MB ;日志文件大小,超出会rotate,默认 50MB,如果设成0,表示不限制大小
logfile_backups=10 ;日志文件保留备份数量默认10,设为0表示不备份
loglevel=info ;日志级别,默认info,其它: debug,warn,trace
nodaemon=false ;是否在前台启动,默认是false,即以 daemon 的方式启动
minfds=1024 ;可以打开的文件描述符的最小值,默认 1024
minprocs=200 ;可以打开的进程数的最小值,默认 200
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.
[inet_http_server]
port=0.0.0.0:9001
[include]
files = /etc/supervisord/conf.d/*.conf
(此处是配置模板,请根据自己需求自行配置)
## 将需要挂载到后台运行的配置文件放置到 /etc/supervisord/conf.d/alter.conf
# 例如:altermanager
[program:alertmanager]
# 程序所在目录
directory = /opt/project/alertmanager/
# 启动程序的命令;
command = /opt/project/alertmanager/alertmanager --config.file=/opt/project/alertmanager/alertmanager.yml --cluster.advertise-address=0.0.0.0:9093
# 在supervisord启动的时候也自动启动;
autostart = true
# 程序异常退出后自动重启;
autorestart = true
# 启动5秒后没有异常退出,就当作已经正常启动了;
startsecs = 5
# 启动失败自动重试次数,默认是3;
startretries = 3
# 启动程序的用户;
user = root
# 把stderr重定向到stdout,默认false;
redirect_stderr = true
# 标准日志输出;
stdout_logfile=/tmp/alertmanager_stdout.log
# 错误日志输出;
stderr_logfile=/tmp/alertmanager_stderr.log
# 标准日志文件大小,默认50MB;
stdout_logfile_maxbytes = 20MB
# 标准日志文件备份数;
stdout_logfile_backups = 20
vim /etc/systemd/system/supervisord.service
[Unit]
Description=supervisord service in golang
After=network.target
[Service]
Type=simple
User=root
StartLimitInterval=5
StartLimitBurst=10
ExecStartPre=/bin/sleep 10
ExecStart=/etc/supervisord/supervisord -c /etc/supervisord/supervisord.conf
Restart=always
RestartSec=120
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start supervisord.service
systemctl status supervisord
root用户下的:
vim /root/.bashrc
普通用户下的:
vim /home/xxx用户/.bashrc
alias supervisorctl='/etc/supervisord/supervisord ctl'
root用户下的:
source /root/.bashrc
普通用户下的:
source /home/xxx用户/.bashrc