Improve web service related aspects
This commit is contained in:
20
internal/handler/stop.go
Normal file
20
internal/handler/stop.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// HandleStop handles the stop signal and exits the program.
|
||||
func HandleStop() {
|
||||
sigCh := make(chan os.Signal, 1)
|
||||
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
sig := <-sigCh
|
||||
log.Printf("[Info] Received signal: %v,stopping...\r\n", sig)
|
||||
os.Exit(0)
|
||||
}()
|
||||
}
|
||||
Reference in New Issue
Block a user