supervisord [golang][带GUI]

最后更新于:2022-04-02 03:49:28

[TOC] > [参考](https://github.com/ochinchina/supervisord) ## 概述 go版本的 supervisord,自带 gui 支持window 与 linux ,window 需要自行编译 **具体用法参考 python的`supervisord`** [supervisor](supervisordgo%E7%89%88%E5%B8%A6gui/supervisor%E5%B8%B8%E8%A7%84%E7%94%A8%E6%B3%95.md) ### 支持 python`[supervisord]` ``` logfile logfile_maxbytes logfile_backups loglevel pidfile minfds minprocs identifier ``` ### 支持 `program:x` 的配置 ``` program command process name numprocs numprocs_start autostart startsecs startretries autorestart exitcodes stopsignal stopwaitsecs stdout_logfile stdout_logfile_maxbytes stdout_logfile_backups redirect_stderr stderr_logfile stderr_logfile_maxbytes stderr_logfile_backups environment priority user directory stopasgroup killasgroup restartpause ``` ## bug 修复 ## 命令行操作 ``` supervisord ctl status supervisord ctl status program-1 program-2 supervisord ctl status group:* supervisord ctl stop program-1 program-2... supervisord ctl stop group:program-1 supervisord ctl stop group:* supervisord ctl stop all supervisord ctl start program-1 program-2... supervisord ctl start group:* supervisord ctl start all supervisord ctl shutdown supervisord ctl reload supervisord ctl signal ... supervisord ctl signal all supervisord ctl pid supervisord ctl fg ``` ## 配置 ### 服务依赖 ``` [program:A] depends_on = B, C [program:B] ... [program:C] ... ``` ### 服务所属 user/group ``` [program:xxx] user = user_name ... ``` or ``` [program:xxx] user = user_name:group_name ... ``` ## 实例 ### hello
main.go ``` package main import ( "net/http" "os" ) var ( port string ) func init() { port = os.Getenv("port") if port=="" { port=":5051" } } func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("hello world")) }) err := http.ListenAndServe(port, nil) if err != nil { panic(err) } } ```

编译为linux 版本
supervisor.conf ``` [program:web] environment=port=":5052" command = /root/main autorestart=true ; 程序崩溃时自动重启 ;redirect_stderr=true ; 重定向输出的日志 ;stdout_logfile = /var/log/supervisor/tornado_server.log ;loglevel=info # command = ./main 可用相对路径 [inet_http_server] port=:9001 ```

启动 ``` ./supervisord -c supervisor.conf ``` 访问: http://ip:9001 可查看gui
';