This commit is contained in:
crusader 2018-04-01 19:07:48 +09:00
parent f9345b120c
commit 1b5760425f
2 changed files with 43 additions and 1 deletions

View File

@ -1,3 +1,4 @@
package: git.loafle.net/overflow/probe-consumer-metric package: git.loafle.net/overflow/probe-consumer-metric
import: import:
- package: github.com/segmentio/kafka-go - package: github.com/segmentio/kafka-go
- package: git.loafle.net/commons_go/logging

43
main.go
View File

@ -1,5 +1,46 @@
package main package main
func main() { import (
"os"
"os/signal"
"syscall"
"git.loafle.net/commons_go/logging"
"git.loafle.net/overflow/probe-consumer-metric/consumer"
)
func init() {
logging.InitializeLogger("")
}
func main() {
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
if err := c.Stop(); err != nil {
logging.Logger().Errorf("Consumer error: %v", err)
}
} }