supervisor守护进程

有三种语言版本,python,golang,c++版本,个人推荐c++,只有几百kb.

python版本

不多说了,有十多年历史,但是需要环境中有python.

golang版本

支持linux,windows,只有一个单文件,和一个配置文件. 官方 https://github.com/ochinchina/supervisord

配置文件 c.conf

[inet_http_server]
port=:9001
#username = 123
#password = 123
[program:gf]
directory=/qq
command=./gf
stdout_logfile = gf.log
startretries=3 #自动重启时间
autostart=true
autorestart=true

运行,自动到后台 ./supervisord -c c.conf -d

c++版本,linux版本非常小700多kb,windows版本也不大

官方 https://gitee.com/love_linger/supervisor windows版本只需要直接填写exe文件路径就行了.

{
   "user" : [
      {
         "account" : "123",
         "pswd" : "123"
      }
   ],
   "watcher" : [
      {
         "cmd" : "./gf",
         "dir" : "/qq",
         "name" : "gf",
         "retry" : 3
      },
      {
         "cmd" : "./weui6",
         "dir" : "/www",
         "name" : "weui6",
         "retry" : 3
      }
   ]
}

启动到后台,123是账号密码 ./supervisor port=9001 daemon