jpillora / overseer

Monitorable, gracefully restarting, self-upgrading binaries in Go (golang)
MIT License
2.29k stars 208 forks source link

graceful restart can not achieve zero-down #66

Open Dev-Jabin opened 3 years ago

Dev-Jabin commented 3 years ago

My project is built on the Beego, Now I want to graceful restart my project with Overseer. When I send kill -SIGUSR2 PID. I found that the current process was closed first, and then fork a new process. This will lead to a period of no work process in the middle, resulting in service denial of access. Unable to achieve zero-down

My project code

func main() { overseer.Run(overseer.Config{ Program: prog, Debug: true, }) }

func prog(state overseer.State) { beego.BConfig.RecoverPanic = true beego.BConfig.Listen.Graceful = false beego.Run() }

Overseer log

2020/12/29 16:36:31 [overseer master] graceful restart triggered 2020/12/29 16:36:31 [overseer master] restart success 2020/12/29 16:36:31 [overseer slave#2] graceful shutdown requested 2020/12/29 16:36:31 [overseer slave#2] timeout. forceful shutdown 2020/12/29 16:36:31 [overseer master] prog exited with 1 2020/12/29 16:36:31 [overseer master] starting /Users/Demo

2020/12/29 16:36:34 [overseer slave#3] run 2020/12/29 16:36:34 [overseer slave#3] start program

Looking forward to your reply, Thank you!

jpillora commented 3 years ago

You must use the overseer.State.Listener to receive zero-down time restarts

On 29 Dec 2020 at 7:38:08 pm, Dev-Jabin notifications@github.com wrote:

My project is built on the Beego, Now I want to graceful restart my project with Overseer. When I send kill -SIGUSR2 PID. I found that the current process was closed first, and then fork a new process. This will lead to a period of no work process in the middle, resulting in service denial of access. Unable to achieve zero-down

My project code

` func main() { overseer.Run(overseer.Config{ Program: prog, Debug: true, }) }

func prog(state overseer.State) { beego.BConfig.RecoverPanic = true beego.BConfig.Listen.Graceful = false beego.Run() } ` Overseer log

` 2020/12/29 16:36:31 [overseer master] graceful restart triggered 2020/12/29 16:36:31 [overseer master] restart success 2020/12/29 16:36:31 [overseer slave#2] graceful shutdown requested 2020/12/29 16:36:31 [overseer slave#2] timeout. forceful shutdown 2020/12/29 16:36:31 [overseer master] prog exited with 1 2020/12/29 16:36:31 [overseer master] starting /Users/Demo

2020/12/29 16:36:34 [overseer slave#3] run 2020/12/29 16:36:34 [overseer slave#3] start program ` Looking forward to your reply, Thank you!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jpillora/overseer/issues/66, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE2X4ZB2EUPQZTQGTAO73TSXGIPBANCNFSM4VM6U4WQ .

Dev-Jabin commented 3 years ago

You must use the overseer.State.Listener to receive zero-down time restarts On 29 Dec 2020 at 7:38:08 pm, Dev-Jabin @.**> wrote: My project is built on the Beego, Now I want to graceful restart my project with Overseer. When I send kill -SIGUSR2 PID*. I found that the current process was closed first, and then fork a new process. This will lead to a period of no work process in the middle, resulting in service denial of access. Unable to achieve zero-down My project code func main() { overseer.Run(overseer.Config{ Program: prog, Debug: true, }) } func prog(state overseer.State) { beego.BConfig.RecoverPanic = true beego.BConfig.Listen.Graceful = false beego.Run() } Overseer log 2020/12/29 16:36:31 [overseer master] graceful restart triggered 2020/12/29 16:36:31 [overseer master] restart success 2020/12/29 16:36:31 [overseer slave#2] graceful shutdown requested 2020/12/29 16:36:31 [overseer slave#2] timeout. forceful shutdown 2020/12/29 16:36:31 [overseer master] prog exited with 1 2020/12/29 16:36:31 [overseer master] starting /Users/Demo 2020/12/29 16:36:34 [overseer slave#3] run 2020/12/29 16:36:34 [overseer slave#3] start program Looking forward to your reply, Thank you! — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#66>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE2X4ZB2EUPQZTQGTAO73TSXGIPBANCNFSM4VM6U4WQ .

Thanks for your replay. Now I update my project code as follows

main code

func main() {
    overseer.Run(overseer.Config{
        Program: prog,
        Address: ":8020",
        Debug:   true, //display log of overseer actions
    })
}

Ps: 8020 is my project listen port

prog code

func prog(state overseer.State) {
    http.Serve(state.Listener, nil)
    beego.BConfig.RecoverPanic = true
    beego.BConfig.Listen.Graceful = false
    beego.Run()
}

But I have another problem, How can I use my previous routers. e.g.

beego.Router("/soccer/biz/ping", &soccer_biz.IndexController{}, "Get:GetPong")

Now I curl http://127.0.0.1:8020/soccer/biz/ping return 404.

How to solve this problem? Thank you!

jpillora commented 3 years ago

http.Serve(state.Listener, nil)

Will run the global HTTP server (nil router), provide your router in the place of nil

On 29 Dec 2020 at 10:00:22 pm, Dev-Jabin notifications@github.com wrote:

You must use the overseer.State.Listener to receive zero-down time restarts … <#> On 29 Dec 2020 at 7:38:08 pm, Dev-Jabin @.**> wrote: My project is built on the Beego, Now I want to graceful restart my project with Overseer. When I send kill -SIGUSR2 PID*. I found that the current process was closed first, and then fork a new process. This will lead to a period of no work process in the middle, resulting in service denial of access. Unable to achieve zero-down My project code func main() { overseer.Run(overseer.Config{ Program: prog, Debug: true, }) } func prog(state overseer.State) { beego.BConfig.RecoverPanic = true beego.BConfig.Listen.Graceful = false beego.Run() } Overseer log 2020/12/29 16:36:31 [overseer master] graceful restart triggered 2020/12/29 16:36:31 [overseer master] restart success 2020/12/29 16:36:31 [overseer slave#2] graceful shutdown requested 2020/12/29 16:36:31 [overseer slave#2] timeout. forceful shutdown 2020/12/29 16:36:31 [overseer master] prog exited with 1 2020/12/29 16:36:31 [overseer master] starting /Users/Demo 2020/12/29 16:36:34 [overseer slave#3] run 2020/12/29 16:36:34 [overseer slave#3] start program Looking forward to your reply, Thank you! — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#66 https://github.com/jpillora/overseer/issues/66>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE2X4ZB2EUPQZTQGTAO73TSXGIPBANCNFSM4VM6U4WQ .

Thanks for your replay. Now I update my project code as follows

main code

func main() {

overseer.Run(overseer.Config{

  Program: prog,

  Address: ":8020",

  Debug:   true, //display log of overseer actions

})

}

Ps: 8020 is my project listen port

prog code

func prog(state overseer.State) {

http.Serve(state.Listener, nil)

beego.BConfig.RecoverPanic = true

beego.BConfig.Listen.Graceful = false

beego.Run()

}

But I have another problem, How can I use my previous routers. e.g.

beego.Router("/soccer/biz/ping", &soccer_biz.IndexController{}, "Get:GetPong")

Now I curl http://127.0.0.1:8020/soccer/biz/ping http://127.0.0.1:8020/soccer/biz/ping return 404.

How to solve this problem? Thank you!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jpillora/overseer/issues/66#issuecomment-752035624, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE2X45RMV2P7IJS4XAAJ6TSXGZENANCNFSM4VM6U4WQ .