openreplay/backend/pkg/terminator/terminator.go
Alexander c6aac11cbf
Heuristics refactoring (#987)
* feat(backend): refactored heuristics service

* feat(backend): refactored db service (moved several events to heuristics)
2023-03-09 09:54:12 +01:00

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)
}