首页 > 其他分享 >supervisor使用详解

supervisor使用详解

时间:2023-05-25 16:26:28浏览次数:55  
标签:supervisor supervisord default supervisorctl server 详解 使用 进程

一 介绍

使用文档:http://supervisord.org/
supervisor是Python开发的c/s服务,是Linux系统下的进程管理工具。
可以监听、启动、停止、重启一个或多个进程
用supervisor管理的进程,当一个进程意外被杀死,supervisor监听到进程死后,会自动将它重启,很方便的做到进程的自动恢复的功能,不在需要自己写脚本来控制

二 安装

2.1 pip安装

# pip install supervisor

#生成配置文件
sudo mkdir /etc/supervisor
# echo_supervisord_conf > /etc/supervisor/supervisord.conf

2.2 使用yum进行安装

# yum install -y epel-release
# yum install -y supervisor

三 配置文件

使用yum安装的supervisor会在/etc/会生成一个supervisor.conf文件及一个supervisor.d文件目录

3.1 主配置文件

[root@test-Server1 supervisord.d]# grep -v "^;" /etc/supervisord.conf |grep -v "^$"
[unix_http_server]
file=/run/supervisor/supervisor.sock   ; (the path to the socket file)
[inet_http_server]         ; inet (TCP) server disabled by default
port=127.0.0.1:9001        ; (ip_address:port specifier, *:port for all iface)
username=user              ; (default is no username (open server))
password=123abc             ; (default is no password (open server))
[supervisord]
logfile=/var/log/supervisor/supervisord.log  ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10          ; (num of main logfile rotation backups;default 10)
loglevel=info               ; (log level;default info; others: debug,warn,trace)
pidfile=/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false              ; (start in foreground if true;default false)
minfds=1024                 ; (min. avail startup file descriptors;default 1024)
minprocs=200                ; (min. avail process descriptors;default 200)
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///run/supervisor/supervisor.sock ; use a unix:// URL  for a unix socket
[include]
files = supervisord.d/*.conf

3.2 配置子配置文件用于监控各个进程

[root@test-Server1 supervisord.d]# cat supervisor_java_one.conf
[program:thrk_erp]
command=/usr/local/java/bin/java -jar /www/wwwroot/renkang-erp/thrk_erp-1.0-SNAPSHOT.jar  --server.port=9527 --spring.profiles.active=self >> /mnt/xinceshi/erp.log
priority=1                    ; 数字越高,优先级越高
numprocs=1                    ; 启动几个进程
autostart=true                ; 随着supervisord的启动而启动
autorestart=true              ; 自动重启
startretries=10               ; 启动失败时的最多重试次数
exitcodes=0                   ; 正常退出代码
stopsignal=KILL               ; 用来杀死进程的信号
stopwaitsecs=10               ; 发送SIGKILL前的等待时间
redirect_stderr=true          ; 重定向stderr到stdout

[program:userservice]
command=/usr/local/java/bin/java -jar  /www/wwwroot/renkang-state/usersevice-1.0-SNAPSHOT.jar --server.port=19999 --spring.profiles.active=self 
priority=1                    ; 数字越高,优先级越高
numprocs=1                    ; 启动几个进程
autostart=false               ; true随着supervisord的启动而启动,即使进程存在,它也会重新启动一个,false就不会重新启动了
autorestart=true              ; 自动重启
startretries=10               ; 启动失败时的最多重试次数
exitcodes=0                   ; 正常退出代码
stopsignal=KILL               ; 用来杀死进程的信号
stopwaitsecs=10               ; 发送SIGKILL前的等待时间
redirect_stderr=true          ; 重定向stderr到stdout


四 启动supervisord

 supervisord -c /etc/supervisord.conf
 systemctl start supervisord.service 

五 supervisor常用命令

supervisorctl status   # 查看进程运行状态
supervisorctl start weather   # 启动进程
supervisorctl stop weather    # 关闭进程
supervisorctl restart weather   # 重启进程
supervisorctl update    # 重新载入配置文件
supervisorctl shutdown    # 关闭 supervisord
supervisorctl clear weather    # 清空进程日志
supervisorctl stop restart + all    # 表示启动,关闭,重启所有进程。

我想启动上面配置好的任务就是supervisorctl start userservice

image

标签:supervisor,supervisord,default,supervisorctl,server,详解,使用,进程
From: https://www.cnblogs.com/huningfei/p/17431670.html

相关文章

  • SpringBoot中使用@Scheduled实现定时任务通过读取配置文件动态开关
    场景SpringBoot中定时任务与异步定时任务的实现:https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/117083609上面讲的通过@Scheduled注解实现简单定时任务的方式。如果定时任务有多个,不同业务场景下需要动态配置某个定时任务的开关。可以通过@ConditionalOnPropert......
  • jQuery.when的使用
    需求:有1000个合同,每次并发处理2个合同(单独对每个合同调用WebAPI接口),每次确保2个合同被处理完毕后等待1秒再继续处理后面2个。//1000个合同的数组varcontracts=[...];//记录当前处理的合同位置varcurrentPosition=0;//处理两个合同并调用WebAPI接口functionproc......
  • 使用lsyncd实时同步文件从一台服务器到另一台服务器
    一背景说明我有3台nginx服务器,想实时同步vhost,html,ssl这三个目录,这样我只是改一台机器的东西,所有服务器上的配置文件也都会被更改,就找到了lsyncd的同步软件,是通过lsyncd结合ssh去实现实时同步的,我这里是想把196上面的3个目录,同步到198和197上.系统:centos7.9lsyncd版本:2......
  • grep -A -B -C使用介绍
    grep-A显示匹配指定内容及之后的n行grep-B 显示匹配指定内容及之前的n行grep-C 显示匹配指定内容及其前后各n行 grep-A5nametest.txt搜索匹配test.txt文件中与”name”字符串匹配的行,并显示其后的5行......
  • python中islice()函数使用
    islice是Python中的一个函数,用于对可迭代对象进行切片操作,可以实现类似于切片操作一样的功能,但又不像切片那样需要先将整个序列读入内存,从而节省内存。islice函数是通过生成器来实现对可迭代对象的切片,从而避免了将整个序列读入内存的限制,可以节省大量的内存。使用islice函数需要......
  • 【Git】git详细使用说明教程
    以下是汇总别人网上写好的,在这里记录一下,方便以后使用权威Git书籍 ProGit(中文版)git官网:http://git-scm.comgit手册:Git-Reference网友整理的Git@osc教程,请点击这里;一份很好的Git入门教程,请点击这里;Git图解教程Git视频教程:Git版本控制器_张果_哔哩哔哩_bilibili一个......
  • 网络灌包命令_iperf工作原理及使用方法
         网络性能评估主要是监测网络带宽的使用率,将网络带宽利用最大化是保证网络性能的基础,但是由于网络设计不合理、网络存在安全漏洞等原因,都会导致网络带宽利用率不高。要找到网络带宽利用率不高的原因,就需要对网络传输进行监控,此时就需要用到一些网络性能评估工具,而Ipe......
  • Fdog系列(三):使用腾讯云短信接口发送短信,数据库写入,部署到服务器,web收尾篇。
    文章目录1.前言2.使用腾讯云短信接口发送短信3.java连接数据库4.部署到服务器(如果你有的话)目录Fdog系列(一):思来想去,不如写一个聊天软件,那就从仿QQ注册页面开始吧。Fdog系列(二):html写完注册页面之后怎么办,用java写后台响应呀。文章中出现的源码获取方式:评论区留下邮箱地址。创作......
  • Centos 7 系统上使用dokcer安装oracle 11g(踩坑验证过可用)
    1.docker安装略2.查看docker中关于oracle11g的镜像,并拉下来dockersearchoracle_11gdockerpulldocker.io/akaiot/oracle_11g此处选择第二个 3.启动临时容器获取初始化数据dockerrun-d--nametest--restartunless-stopped\-p1521:1521docker.io/akaiot/o......
  • Guava cache使用总结
    importcom.google.common.cache.CacheBuilder;importcom.google.common.cache.CacheLoader;importcom.google.common.cache.LoadingCache;importjava.text.SimpleDateFormat;importjava.util.Date;importjava.util.Random;importjava.util.concurrent.TimeUnit;......