Skip to content

Commit

Permalink
refactor: streamline shutdown signal handling (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
s0up4200 authored Dec 30, 2023
1 parent 50100f4 commit acab2d9
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions cmd/omegabrr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func main() {
}()

sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGKILL, syscall.SIGTERM)
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)

schedulerService.Start()

Expand Down Expand Up @@ -225,19 +225,11 @@ func main() {
}()

for sig := range sigCh {
switch sig {
case syscall.SIGHUP:
log.Log().Msg("shutting down server sighup")
schedulerService.Stop()
os.Exit(0)
case syscall.SIGINT, syscall.SIGQUIT:
schedulerService.Stop()
os.Exit(0)
case syscall.SIGKILL, syscall.SIGTERM:
schedulerService.Stop()
os.Exit(0)
}
log.Info().Msgf("Received signal: %v", sig)
schedulerService.Stop()
os.Exit(0)
}

default:
pflag.Usage()
if cmd != "help" {
Expand Down

0 comments on commit acab2d9

Please sign in to comment.