涉及知识点:
overseer: go 平滑重启库 github.com/jpillora/overseer gspt: go 设置进程名字, 方便区分不同进程 github.com/erikdubbelboer/gspt kill [参数] [进程ID] 用于向进程发送信号 例如:kill -HUP 520 转载:https://blog.csdn.net/junyucsdn/article/details/50519248
overseer代码:
package main import "fmt" "github.com/erikdubbelboer/gspt" "github.com/jpillora/overseer" "log" "net/http" ) // 设置进程名字 用户平滑重启(通过向进程发送信号,即可完成重启) func mainInit){ procTitle := "haiyoushui" gspt.SetProcTitleprocTitle) } func main) { mainInit) overseer.Runoverseer.Config{ Program: prog, Address: ":3000", }) } //progstate) runs in a child process func progstate overseer.State) { log.Printf"app %s) listening...", state.ID) http.Handle"/", http.HandlerFuncfuncw http.ResponseWriter, r *http.Request) { fmt.Fprintfw, "app %s) says hello ", state.ID) })) http.Servestate.Listener, nil) }
邮箱: 1090055252@qq.com