cespare / reflex

Run a command when files change
MIT License
3.35k stars 135 forks source link

Reflex: Graceful Shutdown Issue with os.Interrupt Signal Intercept #98

Open lordvidex opened 1 year ago

lordvidex commented 1 year ago

when running a server that has graceful shutdown logic intercepting the os signals, reflex intercepts them and prevent cleanup logic.

escalopa commented 1 year ago

Yeah, I got the same issue, I was running reflex -sr '\.go$' go run ./cmd/main.go where main.go has shutdown function on signals (SIGINT, SIGTERM), But it was not getting triggered

dhax commented 12 months ago

What OS are you on? Because this exact same command is working just fine for me on linux zsh shell. This is my graceful shutdown logic:

server := &http.Server{
    Addr:    ":8000",
    Handler: myHandler,
}

go func() {
    if err := server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
        log.Println("error while listening", err)
    }
}()

done := make(chan os.Signal, 1)
signal.Notify(done, syscall.SIGINT, syscall.SIGTERM)
sig := <-done
log.Println("shutting down...")
...
NoFacePeace commented 12 months ago

感谢您的来信,我尽快回复您!