supervisorctl命令详解

1. 概念

一般在linux中运行某个进程的时候,通过start、stop、restart以及reload进行运行,将其配置的服务放置在/etc/init.d/的目录下

supervisor主要的作用是管理进程,主要通过fork/exec进程对其启动(将其作为子进程),之后supervisor作为父进程对其启动,即使断电宕机也可将其重启,主要在配置文件中书写autostart=true即可。而传统方式的当即重启脚本需要写一个脚本来监控

对比传统方式的书写,supervisor的特性作用比较大


supervisor主要有两个命令参数:

supervisord : 服务端,启动supervisor即启动supervisord服务。

manong@manong-offline27-30001:~/manong/yanjiuseng$ supervisord --help
supervisord -- run a set of applications as daemons.

Usage: /usr/local/bin/supervisord [options]

supervisorctl:客户端,启动supervisor的监控窗口,内有监控的子进程

manong@manong-offline27-30001:~/manong/yanjiuseng$ supervisorctl --help
supervisorctl -- control applications run by supervisord from the cmd line.

Usage: /usr/local/bin/supervisorctl [options] [action [arguments]]

2. 命令讲解

supervisorctl 主要是supervisor的一个客户端管理工具,主要用来管理进程

下载这个命令完成之后,其命令的配置文件路径在:cat /etc/supervisor/supervisord.conf

查询所有的子进程状态:supervisorctl status,执行supervisorctl是进到这个命令的内部
具体的参数讲解:
子进程名
运行状态(RUNNING、FATAL、STOPPED、STARTING
进程号或者子进程的运行时间

  • 查看单个子进程的状态: supervisorctl status 子进程
  • 关闭单个子进程 :supervisorctl stop 子进程
  • 关闭所有子进程:supervisorctl stop all
  • 启动单个子进程:supervisorctl start 子进程
  • 启动所有子进程:supervisorctl start all
  • 重启单个子进程:supervisorctl restart 子进程

3. 配置文件
将其脚本配置在文件中
其配置文件的详解具体如下:(我的目录在conf文件下)

[program:xx_ccd]
# 进入到这个目录下
directory=/home/xx

# 执行虚拟环境的命令
command=/home/xx/.virtualenvs/manong/bin/uwsgi    --ini uwsgi.ini

# 用户名是这个
user=test_user
numprocs=1

# 日志文件
stdout_logfile=/home/xx/logs/uwsgi.log


redirect_stderr=true
autostart=false
autorestart=true
startsecs=5
stopwaitsecs=10
killasgroup=true
priority=999
stopsignal=QUIT

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值