“Supervisor基础”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
 
(未显示同一用户的32个中间版本)
第1行: 第1行:
 
= 常识=
 
= 常识=
 +
[ˌsupərˈvaɪzərz] supervisors 监督人
 
  Supervisor(http://supervisord.org/)是用Python开发的一个client/server服务,是Linux/Unix系统下的一个进程管理工具,不支持Windows系统。它可以很方便的监听、启动、停止、重启一个或多个进程。用Supervisor管理的进程,当一个进程意外被杀死,supervisort监听到进程死后,会自动将它重新拉起,很方便的做到进程自动恢复的功能,不再需要自己写shell脚本来控制
 
  Supervisor(http://supervisord.org/)是用Python开发的一个client/server服务,是Linux/Unix系统下的一个进程管理工具,不支持Windows系统。它可以很方便的监听、启动、停止、重启一个或多个进程。用Supervisor管理的进程,当一个进程意外被杀死,supervisort监听到进程死后,会自动将它重新拉起,很方便的做到进程自动恢复的功能,不再需要自己写shell脚本来控制
 +
 +
=install=
 +
  sudo yum install epel-release -y
 +
  yum install supervisor -y
 +
  yum install rsync  # 有d的 这个不对 supervisord
 +
 +
=一些常用配置=
 +
<pre>
 +
minprocs=200                ;可以打开的进程数的最小值,默认 200
 +
</pre>
 +
 +
=常用命令=
 +
<pre>
 +
#只重启特定的任务
 +
supervisorctl restart chat-im-message: client-user-connection: room-statistic-event: robot-comment:  robot-praise:
 +
名如下 [program:robot-praise]
 +
 +
#stop
 +
supervisorctl stop chat-auto-service-timer:
 +
 +
#启动可能要加*
 +
supervisorctl start chat-im-message:*
 +
 +
</pre>
  
 
=lx=
 
=lx=
 
<pre>
 
<pre>
 +
ss
 +
 +
[program:policy-renewal-s]
 +
process_name=%(program_name)s_%(process_num)02d
 +
directory=e/server/ab.com
 +
command=php artisan policy*renewal@queue:handle
 +
autostart=true
 +
autorestart=true
 +
user=apache
 +
numprocs=1
 +
redirect_stderr=true
 +
stdout_logfile=/var/log/supervisor/e.log
 +
 +
 +
#LXTX
 
  php-worker]# cat supervisord.conf
 
  php-worker]# cat supervisord.conf
 
[supervisord]
 
[supervisord]
第53行: 第93行:
 
bash终端
 
bash终端
  
 +
supervisorctl reload
 
supervisorctl status
 
supervisorctl status
 
supervisorctl stop tomcat
 
supervisorctl stop tomcat
第60行: 第101行:
 
supervisorctl update
 
supervisorctl update
  
 +
查看单个任务状态: supervisorctl status 服务名
  
 
开机启动Supervisor服务
 
开机启动Supervisor服务
第91行: 第133行:
 
chmod 766 supervisor.service
 
chmod 766 supervisor.service
  
 +
 +
</pre>
 +
 +
=trouble shooting=
 +
 +
记得要  supervisorctl reload
 +
求助!supervisord 报错 FATAL Exited too quickly (process log may have details)
 +
 +
entered FATAL state, too many start retries too quickly
 +
 +
我 user 改成 root 之后可以了
 +
 +
 +
supervisor 比较适合监控业务应用,且只能监控前台程序,php fork方式实现的daemon不能用它监控,否则supervisor> status 会提示:BACKOFF  Exited too quickly (process log may have details)
 +
 +
 +
<pre>
 +
 +
# supervisorctl restart handle-user-question:
 +
handle-user-question: ERROR (no such group)
 +
handle-user-question: ERROR (no such group)
 +
 +
[root@idc-test-all-other-192-168-10-121-c7 ~] {19:33:15} (0)
 +
# supervisorctl reload
 +
Restarted supervisord
 +
 +
可能要重启
 +
 +
supervisorctl restart handle-user-question:
 +
 +
 +
Jan 11 2022
 +
sync_original_data_insurance_company:sync_original_data_insurance_company_00                    BACKOFF  Exited too quickly (process log may have details)
 +
 +
web目录多了个目录层
  
 
</pre>
 
</pre>
  
 
=see also=
 
=see also=
 +
 +
[https://zhuanlan.zhihu.com/p/29145108 Supervisor是一枚大坑]
 +
 +
[http://www.xiaoxiaoguo.cn/python/supervisor-notice.html # 关于supervisor要注意的点]
 +
 +
[https://zhuanlan.zhihu.com/p/98097523?from_voters_page=true supervisor入门]
  
 
[https://blog.csdn.net/xyang81/article/details/51555473 Supervisor安装与配置(Linux/Unix进程管理工具)]
 
[https://blog.csdn.net/xyang81/article/details/51555473 Supervisor安装与配置(Linux/Unix进程管理工具)]
  
 +
[https://www.cnblogs.com/phonecom/p/10833697.html  good Exited too quickly (process log may have details)-配置问题 ]
 +
 +
[https://www.jianshu.com/p/f8735b039c67 supervisor常用命令]
 +
 +
[https://www.cnblogs.com/xueweihan/p/6195824.html supervisor 安装、配置、常用命令]
 +
 +
[https://www.cnblogs.com/xueweihan/p/6195824.html  supervisor 安装、配置、常用命令 ]
 +
 +
[https://www.jianshu.com/p/0b9054b33db3 Supervisor使用详解]
 +
 +
[https://blog.csdn.net/shuyun123456789/article/details/51153961  Supervisor重新加载配置启动新的进程]
 +
 +
[https://www.jianshu.com/p/0226b7c59ae2 Supervisor的作用与配置]
 +
 +
[https://www.cnblogs.com/jasonkoo/articles/3750638.html supervisord简介,配置及使用]
 +
 +
 +
[https://www.liaoxuefeng.com/article/895919885120064 Linux后台进程管理利器:supervisor]
 +
 +
 +
[https://imwz.io/run-horizon-by-supervisord-in-laradock/ Run Horizon by Supervisord in Laradock]
 +
 +
[https://blog.csdn.net/weixin_43343144/article/details/97688485 非常重要】运行supervisorctl错误提示【FATAL或BACKOFF 】Exited too quickly (process log may have details)问题总结]
 +
 +
[https://www.jianshu.com/p/9abffc905645 supervisor初体验]
 +
 +
[https://www.cnblogs.com/zzqit/p/10107195.html  使用supervisor管理后台进程 ]
 
[[category:ops]]
 
[[category:ops]]

2023年3月3日 (五) 08:00的最新版本

常识

[ˌsupərˈvaɪzərz] supervisors 监督人 
Supervisor(http://supervisord.org/)是用Python开发的一个client/server服务,是Linux/Unix系统下的一个进程管理工具,不支持Windows系统。它可以很方便的监听、启动、停止、重启一个或多个进程。用Supervisor管理的进程,当一个进程意外被杀死,supervisort监听到进程死后,会自动将它重新拉起,很方便的做到进程自动恢复的功能,不再需要自己写shell脚本来控制

install

 sudo yum install epel-release -y
 yum install supervisor -y
 yum install rsync  # 有d的 这个不对 supervisord

一些常用配置

minprocs=200                 ;可以打开的进程数的最小值,默认 200

常用命令

#只重启特定的任务 
supervisorctl restart chat-im-message: client-user-connection: room-statistic-event: robot-comment:  robot-praise:
 名如下 [program:robot-praise]

#stop
supervisorctl stop chat-auto-service-timer:

#启动可能要加*
supervisorctl start chat-im-message:*

lx

ss

[program:policy-renewal-s]
process_name=%(program_name)s_%(process_num)02d
directory=e/server/ab.com
command=php artisan policy*renewal@queue:handle
autostart=true
autorestart=true
user=apache
numprocs=1
redirect_stderr=true
stdout_logfile=/var/log/supervisor/e.log


#LXTX
 php-worker]# cat supervisord.conf
[supervisord]
logfile=/tmp/supervisord.log ; main log file; default $CWD/supervisord.log
logfile_maxbytes=50MB        ; max main logfile bytes b4 rotation; default 50MB
logfile_backups=10           ; # of main logfile backups; 0 means none, default 10
loglevel=debug               ; log level; default info; others: debug,warn,trace
pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid22
nodaemon=true
user=www-data
[supervisorctl]
[inet_http_server]
port = *:9001
#username="yourusername"
#password="yourpass"
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface


[include]
files = /var/www/api.sns.cai.com/supervisord.d/production1.*.conf /var/www/apistatistical.cai.com/supervise/production1.*.conf

#from laradock
tree   supervisord.d/
supervisord.d/
├── laravel-worker.conf.example
└── monitor-mail.conf



以tomcat 举例


Tomcat进程的一个例子:

[program:tomcat]
command=/opt/apache-tomcat-8.0.35/bin/catalina.sh run
stdout_logfile=/opt/apache-tomcat-8.0.35/logs/catalina.out
autostart=true
autorestart=true
startsecs=5
priority=1
stopasgroup=true
killasgroup=true


bash终端

supervisorctl reload
supervisorctl status
supervisorctl stop tomcat
supervisorctl start tomcat
supervisorctl restart tomcat
supervisorctl reread
supervisorctl update

查看单个任务状态: supervisorctl status 服务名

开机启动Supervisor服务
7.1 配置systemctl服务

1> 进入/lib/systemd/system目录,并创建supervisor.service文件

[Unit]
Description=supervisor
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/bin/supervisorctl $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

2> 设置开机启动

systemctl enable supervisor.service
systemctl daemon-reload

3、修改文件权限为766

chmod 766 supervisor.service


trouble shooting

记得要  supervisorctl reload
求助!supervisord 报错 FATAL Exited too quickly (process log may have details)

entered FATAL state, too many start retries too quickly

我 user 改成 root 之后可以了


supervisor 比较适合监控业务应用,且只能监控前台程序,php fork方式实现的daemon不能用它监控,否则supervisor> status 会提示:BACKOFF Exited too quickly (process log may have details)



# supervisorctl restart handle-user-question:
handle-user-question: ERROR (no such group)
handle-user-question: ERROR (no such group)

[root@idc-test-all-other-192-168-10-121-c7 ~] {19:33:15} (0)
# supervisorctl reload
Restarted supervisord

可能要重启 

supervisorctl restart handle-user-question:


Jan 11 2022
sync_original_data_insurance_company:sync_original_data_insurance_company_00                     BACKOFF   Exited too quickly (process log may have details)

web目录多了个目录层

see also

Supervisor是一枚大坑

# 关于supervisor要注意的点

supervisor入门

Supervisor安装与配置(Linux/Unix进程管理工具)

good Exited too quickly (process log may have details)-配置问题

supervisor常用命令

supervisor 安装、配置、常用命令

supervisor 安装、配置、常用命令

Supervisor使用详解

Supervisor重新加载配置启动新的进程

Supervisor的作用与配置

supervisord简介,配置及使用


Linux后台进程管理利器:supervisor


Run Horizon by Supervisord in Laradock

非常重要】运行supervisorctl错误提示【FATAL或BACKOFF 】Exited too quickly (process log may have details)问题总结

supervisor初体验

使用supervisor管理后台进程