企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] > [github.com](https://github.com/mattn/goreman) ## 安装 `go get github.com/mattn/goreman` ## 概述 控制多个服务的批量启动与单独启动 ## 实例1 同级目录创建 Procfile与main.go <details> <summary>Procfile</summary> ``` web1: main.exe -p :9002 goweb: main.exe -p :9003 ``` </details> <br/> <details> <summary>main.go</summary> ``` package main import ( "flag" "fmt" "net/http" "os" ) var addr = flag.String("p", ":8080", "address") func main() { flag.Parse() http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "hello "+os.Getenv("AUTHOR")) }) http.ListenAndServe(*addr, nil) } ``` </details> <br/> 执行 ``` > goreman.exe start 09:59:17 web1 | Starting web1 on port 5000 09:59:17 goweb | Starting goweb on port 5100 > goreman.exe run status *web1 *goweb > goreman.exe run stop goweb > goreman.exe run status *web1 goweb ``` ## 实例2 可按顺序启动,如下 ``` # 先启动Zookeeper goreman run start zookeeper # 然后启动kafka goreman run start broker # 查看进程状态 goreman run status # 停止broker进程 goreman run stop broker # 重启broker进程 goreman run restart broker ```