• supervisor 安装脚本


    mkdir /data/tools && cd /data/tools
    wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
    sudo python ez_setup.py --insecure
    wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
    tar -xf pip-9.0.1.tar.gz
    cd pip-9.0.1
    sudo python setup.py install
    sudo easy_install supervisor
    sudo mkdir /etc/supervisor
    sudo mkdir /etc/supervisor/conf
    sudo chown wwwad.wwwad /etc/supervisor/ -R
    echo_supervisord_conf > /etc/supervisor/supervisord.conf
    mkdir /data/supervisor/
    supervisord.conf 配置文件内容为
    ; Sample supervisor config file.
    ;
    ; For more information on the config file, please see:
    ; http://supervisord.org/configuration.html
    ;
    ; Notes:
    ;  - Shell expansion ("~" or "$HOME") is not supported.  Environment
    ;    variables can be expanded using this syntax: "%(ENV_HOME)s".
    ;  - Quotes around values are not supported, except in the case of
    ;    the environment= options as shown below.
    ;  - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
    ;  - Command will be truncated if it looks like a config file comment, e.g.
    ;    "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".
    
    [unix_http_server]
    file=/data/supervisor/supervisor.sock   ; the path to the socket file
    chmod=0700                 ; socket file mode (default 0700)
    chown=wwwad:wwwad       ; socket file uid:gid owner
    ;username=user              ; default is no username (open server)
    ;password=123               ; default is no password (open server)
    
    ;[inet_http_server]         ; inet (TCP) server disabled by default
    ;port=9100        ; ip_address:port specifier, *:port for all iface
    ;username=admin              ; default is no username (open server)
    ;password=kongzg!@#               ; default is no password (open server)
    
    [supervisord]
    logfile=/data/supervisor/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=info                ; log level; default info; others: debug,warn,trace
    pidfile=/data/supervisor/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
    ;umask=022                   ; process file creation umask; default 022
    user=wwwad                 ; default is current user, required if root
    ;identifier=supervisor       ; supervisord identifier, default is 'supervisor'
    ;directory=/tmp              ; default is not to cd during start
    ;nocleanup=true              ; don't clean up tempfiles at start; default false
    ;childlogdir=/tmp            ; 'AUTO' child log dir, default $TEMP
    ;environment=KEY="value"     ; key value pairs to add to environment
    ;strip_ansi=false            ; strip ansi escape codes in logs; def. false
    
    ; The rpcinterface:supervisor 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:x] sections.
    
    [rpcinterface:supervisor]
    supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
    
    ; The supervisorctl section configures how supervisorctl will connect to
    ; supervisord.  configure it match the settings in either the unix_http_server
    ; or inet_http_server section.
    
    [supervisorctl]
    serverurl=unix:///data/supervisor/supervisor.sock ; use a unix:// URL  for a unix socket
    ;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
    ;username=chris              ; should be same as in [*_http_server] if set
    ;password=123                ; should be same as in [*_http_server] if set
    ;prompt=mysupervisor         ; cmd line prompt (default "supervisor")
    ;history_file=~/.sc_history  ; use readline history if available
    
    ; The sample program section below shows all possible program subsection values.
    ; Create one or more 'real' program: sections to be able to control them under
    ; supervisor.
    
    ;[program:theprogramname]
    ;command=/bin/cat              ; the program (relative uses PATH, can take args)
    ;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
    ;numprocs=1                    ; number of processes copies to start (def 1)
    ;directory=/tmp                ; directory to cwd to before exec (def no cwd)
    ;umask=022                     ; umask for process (default None)
    ;priority=999                  ; the relative start priority (default 999)
    ;autostart=true                ; start at supervisord start (default: true)
    ;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
    ;startretries=3                ; max # of serial start failures when starting (default 3)
    ;autorestart=unexpected        ; when to restart if exited after running (def: unexpected)
    ;exitcodes=0,2                 ; 'expected' exit codes used with autorestart (default 0,2)
    ;stopsignal=QUIT               ; signal used to kill process (default TERM)
    ;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
    ;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
    ;killasgroup=false             ; SIGKILL the UNIX process group (def false)
    ;user=chrism                   ; setuid to this UNIX account to run the program
    ;redirect_stderr=true          ; redirect proc stderr to stdout (default false)
    ;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
    ;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
    ;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
    ;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
    ;stdout_events_enabled=false   ; emit events on stdout writes (default false)
    ;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
    ;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
    ;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
    ;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
    ;stderr_events_enabled=false   ; emit events on stderr writes (default false)
    ;environment=A="1",B="2"       ; process environment additions (def no adds)
    ;serverurl=AUTO                ; override serverurl computation (childutils)
    
    ; The sample eventlistener section below shows all possible eventlistener
    ; subsection values.  Create one or more 'real' eventlistener: sections to be
    ; able to handle event notifications sent by supervisord.
    
    ;[eventlistener:theeventlistenername]
    ;command=/bin/eventlistener    ; the program (relative uses PATH, can take args)
    ;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
    ;numprocs=1                    ; number of processes copies to start (def 1)
    ;events=EVENT                  ; event notif. types to subscribe to (req'd)
    ;buffer_size=10                ; event buffer queue size (default 10)
    ;directory=/tmp                ; directory to cwd to before exec (def no cwd)
    ;umask=022                     ; umask for process (default None)
    ;priority=-1                   ; the relative start priority (default -1)
    ;autostart=true                ; start at supervisord start (default: true)
    ;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
    ;startretries=3                ; max # of serial start failures when starting (default 3)
    ;autorestart=unexpected        ; autorestart if exited after running (def: unexpected)
    ;exitcodes=0,2                 ; 'expected' exit codes used with autorestart (default 0,2)
    ;stopsignal=QUIT               ; signal used to kill process (default TERM)
    ;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
    ;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
    ;killasgroup=false             ; SIGKILL the UNIX process group (def false)
    ;user=chrism                   ; setuid to this UNIX account to run the program
    ;redirect_stderr=false         ; redirect_stderr=true is not allowed for eventlisteners
    ;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
    ;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
    ;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
    ;stdout_events_enabled=false   ; emit events on stdout writes (default false)
    ;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
    ;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
    ;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
    ;stderr_events_enabled=false   ; emit events on stderr writes (default false)
    ;environment=A="1",B="2"       ; process environment additions
    ;serverurl=AUTO                ; override serverurl computation (childutils)
    
    ; The sample group section below shows all possible group values.  Create one
    ; or more 'real' group: sections to create "heterogeneous" process groups.
    
    ;[group:thegroupname]
    ;programs=progname1,progname2  ; each refers to 'x' in [program:x] definitions
    ;priority=999                  ; the relative start priority (default 999)
    
    ; 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 = relative/directory/*.ini
    
    [include]
    files = /etc/supervisor/conf/*.conf 



    program 的配置文件
    [program: test]
    command=xxxxxxxx  ;如果有多条命令,可以写入shell脚本再在这里调用
    directory=xxxxx        ;执行命令时切换到的目录
    user=xxxx ;执行命令所用的linux用户身份
    autorestart=true    ;是否自动重启
    autostart=true ;启动supervisor时是否自行启动该程序
    redirect_stderr=true    ;如果为true则将stderr发送到stdout相应的log文件中去
    stdout_logfile=/path/to/logfile ;制定stdout的输出文件
    stdout_logfile_maxbytes=10MB    ;限定logfile的大小, 默认为50M
    stdout_logfile_backups=10 ;保存logfile的最大数目,如果操作这个数目则对最早的logfile进行覆盖,默认为10
    environment=A="1", B="2" ;设置环境变量,这里可以保存运行程序需要的参数 
    
    这里记住,我们每添加一次program的时候,我们需要更新新的配置到supervisord
    supervisorctl update
    
    这里的supervisorctl reload的功能是重启所有的程序
    
    启动某一个程序
    supervisorctl start programe_name
    
    
    一、添加好配置文件后
    
    二、更新新的配置到supervisord    
        supervisorctl update  
    
    三、重新启动配置中的所有程序
      supervisorctl reload  
    
    四、启动某个进程(program_name=你配置中写的程序名称)
     supervisorctl start program_name  
    
    五、查看正在守候的进程
    supervisorctl  status
    
    六、停止某一进程 (program_name=你配置中写的程序名称)
    spervisorctl stop program_name  
    
    七、重启某一进程 (program_name=你配置中写的程序名称)
    supervisorctl restart program_name  
    
    八、停止全部进程
    supervisorctl stop all  
    
    注意:显示用stop停止掉的进程,用reload或者update都不会自动重启。
    
    
    
    supervisor 执行命令的额时候报一下错误
    Error: .ini file does not include supervisorctl section  
    For help, use /usr/local/bin/supervisorctl -h  
    
    或者 
    
    error: <class 'socket.error'>, [Errno 101] Network is unreachable: file: /usr/lib64/python2.6/socket.py line: 567
    
    
    这个时候
    
    切换到/etc/supervisor目录执行以上的命令
    
    
  • 相关阅读:
    PL/SQL中判断字段为空
    ArrayList知识详解
    那些碰到过的异常
    Java中的==和equals( )方法
    String,StringBuilder和StringBuffer
    树莓派3b+_32位linux系统arm架构安装JDK
    [杂]右键拷贝文件路径
    [023]模板成员函数为什么不能是虚函数
    [杂]几个好玩的网址
    [022]c++虚函数、多态性与虚表
  • 原文地址:https://www.cnblogs.com/smail-bao/p/8257375.html
Copyright © 2020-2023  润新知