GO overseer 平滑重启

涉及知识点:

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.SetProcTitle(procTitle)
}

func main() {
    mainInit()
  
    overseer.Run(overseer.Config{
        Program: prog,
        Address: ":3000",
    })
}

//prog(state) runs in a child process
func prog(state overseer.State) {
    log.Printf("app (%s) listening...", state.ID)
    http.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, "app (%s) says hello
", state.ID)
    }))
    http.Serve(state.Listener, nil)
}

邮箱: 1090055252@qq.com

Published by

风君子

独自遨游何稽首 揭天掀地慰生平

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注