supervisor

1、安装及启动

sudo apt-get install supervisor
/etc/init.d/supervisor start

2、配置、reload配置

sudo vim /etc/supervisor/supervisord.conf 
sudo supervisorctl reload
/etc/init.d/supervisor restart
simon@ubuntu:~/testpid$ sudo supervisorctl status
[sudo] password for simon: 
testpid                          STOPPED   Jun 07 02:21 PM
simon@ubuntu:~/testpid$ 

3、supervisorctl

supervisorctl reload :修改完配置文件后重新启动
supervisor supervisorctl status :查看supervisor
监管的进程状态 supervisorctl start 进程名 :启动XXX进程 
supervisorctl stop 进程名 :停止XXX进程 
supervisorctl stop all:停止全部进程,注:start、restart、stop都不会载入最新的配置文件。 
supervisorctl update:根据最新的配置文件,启动新配置或有改动的进程,配置没有改动的进程不会受影响而重启

具体配置

 1 ; supervisor config file
  2 
  3 [unix_http_server]
  4 file=/var/run/supervisor.sock   ; (the path to the socket file)
  5 chmod=0700                       ; sockef file mode (default 0700)
  6 
  7 [supervisord]
  8 logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/su    pervisord.log)
  9 pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.    pid)
 10 childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default     $TEMP)
 11 
 12 ; the below section must remain in the config file for RPC
 13 ; (supervisorctl/web interface) to work, additional interfaces may be
 14 ; added by defining them in separate rpcinterface: sections
 15 [rpcinterface:supervisor]
 16 supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinter    face
 17 
 18 [supervisorctl]
 19 serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix so    cket
 20 
 21 ; The [include] section can just contain the "files" setting.  This
 22 ; setting can list multiple files (separated by whitespace or
 23 ; newlines).  It can also contain wildcards.  The filenames are
 24 ; interpreted as relative to this file.  Included files *cannot*
 25 ; include files themselves.
 26 
 27 [include]
 28 files = /etc/supervisor/conf.d/*.conf
 29 
 30 [inet_http_server]
 31 port=127.0.0.1:9001
 32 username=123
 33 password=123
 34 
 35 [program:testpid]
 36 command=bash start.sh
 37 numprocs=1
 38 directory=/usr/local/bin
 39 autorestart=true
 40 redirect_stderr=true
 41 stdout_file=/var/log/supervisord/testpid.log ;需要手动创建目录
 42 loglevel=info
 43 user=ubuntu           ; 用哪个用户启动
 44 stdout_logfile_maxbytes = 20MB  ; stdout 日志文件大小,默认 50MB
 45 stdout_logfile_backups = 2      ; stdout 日志文件备份数

web页面
这里写图片描述

进程杀掉后会自动重启(配置里面需配置)
这里写图片描述

官方文档:
http://supervisord.org/configuration.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值