2018-04-01 09:59:30 +00:00
|
|
|
package main
|
|
|
|
|
2018-04-01 10:07:48 +00:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
|
|
|
|
|
|
|
"git.loafle.net/commons_go/logging"
|
|
|
|
"git.loafle.net/overflow/probe-consumer-metric/consumer"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
logging.InitializeLogger("")
|
|
|
|
}
|
|
|
|
|
2018-04-01 09:59:30 +00:00
|
|
|
func main() {
|
2018-04-01 10:07:48 +00:00
|
|
|
defer logging.Logger().Sync()
|
|
|
|
|
|
|
|
var c consumer.Consumer
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
c = consumer.New()
|
|
|
|
if err := c.Start(); err != nil {
|
|
|
|
logging.Logger().Error(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// // Set up channel on which to send signal notifications.
|
|
|
|
// // We must use a buffered channel or risk missing the signal
|
|
|
|
// // if we're not ready to receive when the signal is sent.
|
|
|
|
interrupt := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(interrupt,
|
|
|
|
syscall.SIGKILL,
|
|
|
|
syscall.SIGSTOP,
|
|
|
|
syscall.SIGHUP,
|
|
|
|
syscall.SIGINT,
|
|
|
|
syscall.SIGTERM,
|
|
|
|
syscall.SIGQUIT)
|
|
|
|
|
|
|
|
<-interrupt
|
2018-04-01 09:59:30 +00:00
|
|
|
|
2018-04-01 10:07:48 +00:00
|
|
|
if err := c.Stop(); err != nil {
|
|
|
|
logging.Logger().Errorf("Consumer error: %v", err)
|
|
|
|
}
|
2018-04-01 09:59:30 +00:00
|
|
|
}
|