Xiaopei's DokuWiki

These are the good times in your life,
so put on a smile and it'll be alright

User Tools

Site Tools


it:supervisor

supervisor, supervisord

supervisor

  • reload configs
    supervisorctl reread
    supervisorctl update
  • [program:foo] 常用的选项
    • stdout_logfile=/var/log/supervisor/foo.stdout.log
    • stderr_logfile=/var/log/supervisor/foo.stderr.log
    • user=antoine
  • stopsignal 默认为 TERM,即 kill 的默认信号,所以默认配置下 kill 一个 supervisor 启动的进程,它不会重启
    • $ man kill
           1       HUP (hang up)
           2       INT (interrupt)
           3       QUIT (quit)
           6       ABRT (abort)
           9       KILL (non-catchable, non-ignorable kill)
           14      ALRM (alarm clock)
           15      TERM (software termination signal), default
  • 对应容易出错的还有 exitcodes,如果程序因为异常退出退出码又 不是 非0,默认是不会重启的
  • 因为默认 autorestart=unexpected,应该 autorestart=true

centos

  • centos 用 yum 安装的 supervisor 可能为 v2,太低,不支持 [include] 配置(v3 才加入的)。需要用 pip 更新
    • pip install --upgrade supervisor
  • 需要在配置文件里加入 [include] 配置来支持拆分服务配置
    • [include]
      files = /etc/supervisor/conf.d/*.ini
  • 需要如下修改配置文件,以支持 supervisorctl
    • [unix_http_server]
      file = /var/tmp/supervisor.sock ;
      
      [rpcinterface:supervisor]
      supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
      
      [supervisorctl]
      serverurl=unix:///var/tmp/supervisor.sock ; use a unix:// URL  for a unix socket
  • 需要在启动脚本里加入使用的配置,避免启动时的 warning
    • daemon supervisord -c /etc/supervisord.conf
it/supervisor.txt · Last modified: 2017/03/01 23:08 by admin