lestrrat-go / server-starter

Go port of start_server utility (Server::Starter)
MIT License
215 stars 21 forks source link

Add: a method which hook after graceful shutdown. #16

Closed sioncojp closed 7 years ago

sioncojp commented 7 years ago

https://github.com/lestrrat/go-server-starter/blob/master/starter.go#L429

I wanna hook after graceful shutdown.

The line of target in which graceful restart logic is called syscall.SIGTERM. (Unfortunately, the line is naming s.signalOnHUP. That identification's PR is https://github.com/lestrrat/go-server-starter/pull/14

I've hooked to receive a channel calling syscall.SIGTERM,

// create a hook point to receive a channel in my main.go
case syscall.SIGTERM:
  want execute logic after shutdown....

but it has executed both graceful restart and shutdown.

Because L429 calls SIGTERM to kill process in graceful restart logic. And so a hook point wrong recieved SIGTERM.

What do you think about that it should be a method which hook after graceful shutdown?

lestrrat commented 7 years ago

Because L429 calls SIGTERM to kill process in graceful restart logic.

Use start_server --signal-on-hup=XXX to change the signal that gets sent when HUP is sent to start_server

sioncojp commented 7 years ago

I got it. Thank you!!! Close this PR.