Improve web service related aspects

This commit is contained in:
2025-11-22 17:09:25 +08:00
parent 2a3ef3e52a
commit 27fc5c1fd6
7 changed files with 158 additions and 6 deletions

20
internal/handler/stop.go Normal file
View 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: %vstopping...\r\n", sig)
os.Exit(0)
}()
}