Supervisor 安装

安装 supervisor

yum install supervisor -y

配置

打开 /etc/supervisord.conf,配置 port 和密码

vim /etc/supervisord.conf

配置示例:

[inet_http_server]    ; inet (TCP) server disabled by default
port=*:9000           ; (ip_address:port specifier, *:port for all iface)
username=admin        ; (default is no username (open server))
password=mypasswoord  ; (default is no password (open server))

启动服务:

supervisord -c /etc/supervisord.conf

设置开机自动启动

systemctl enable supervisord

添加项目进程

在 /etc/supervisord.conf 文件中追加 program 配置

vim /etc/supervisord.conf

配置示例:

[program:test_program]
directory=/apps/test_program
command= java -jar test_program.jar
user=root
priority=1
numprocs=1
autostart=true
autorestart=true
startretries=9999
stopsignal=KILL
stopwaitsecs=10
redirect_stderr=true
stdout_logfile=/apps/test_program/log
stdout_logfile_maxbytes=1000MB
stdout_logfile_backups=10

使配置生效:

supervisorctl update

验证

curl --user admin:mypasswoord localhost:9000

有正常响应,说明成功!也可以通过外网用浏览器打开,但要注意安全!