supervisord安装使用

supervisord安装使用

supervisord简介:

supervisord是一个c/s模式的进程管理程序,它可以用来监控应用程序的进程,并且可以管理应用程序的start/stop/restart/reload等功能。

安装supervisord:

root@dokcer:~# apt-get install supervisord -y   #apt安装supervisord
root@dokcer:~# supervisord -v                   #supervisord版本
3.3.1

supervisord配置文件:

supervisord配置文件默认路径:/etc/supervisor/supervisord.conf
root@dokcer:~# vim /etc/supervisor/supervisord.conf

; supervisor config file

[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)

; 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.

[include]
files = /etc/supervisor/conf.d/*.conf   #进程监控配置路径

[inet_http_server]     #web页面端口
port=*:9080            #web页面地址:9080或*:9080
username=admin         #web页面的用户名和密码
password=admin

supervisord监控进程配置文件:

#配置监控的应用程序:
root@dokcer:~# vim /etc/supervisor/conf.d/prometheus.conf
#用户程序为prometheus
[program:prometheus]
#启动命令,不能使用nohup等后台运行命令否则应用程序会无限重启
command=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml
autostart=true  #自动启动
autorestart=true  #自动重启
process_name=prometheus  #进程名称
startretries=5  #尝试启动的次数

启动supervisord程序:

root@dokcer:~# systemctl start supervisor.service #

打开http://IP:9080,输入用户名和密码就可以在web页面查看监控的应用程序:

https://s2.loli.net/2022/07/19/KM4fe6FHTSZNbjQ.png

supervisordctl命令行

命令参数作用
supervisorctlstop program:name停止配置文件中的某个应用程序
supervisorctlstart program:name启动配置文件中的某个应用程序
supervisorctlrestart program:name重启配置文件中的某个应用程序
supervisorctlstop all停止全部进程
supervisorctlrelod载入新配置文件然后启动应用程序
supervisorctlupdate载入新配置文件启动,没有改变就不重启进程
supervisorctltail program:name查看应用程序的日志
root@dokcer:~# supervisorctl start prometheus
prometheus: started
root@dokcer:~# supervisorctl stop prometheus
prometheus: stopped
root@dokcer:~#
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值