* feat(backend): refactored heuristics service * feat(backend): refactored db service (moved several events to heuristics)
22 lines
386 B
Go
22 lines
386 B
Go
package terminator
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
)
|
|
|
|
// ServiceStopper is a common interface for all services
|
|
type ServiceStopper interface {
|
|
Stop()
|
|
}
|
|
|
|
func Wait(s ServiceStopper) {
|
|
sigChan := make(chan os.Signal, 1)
|
|
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
|
|
sig := <-sigChan
|
|
log.Printf("Caught signal %v: terminating\n", sig)
|
|
s.Stop()
|
|
os.Exit(0)
|
|
}
|