34 lines
657 B
Go
34 lines
657 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"git.sendico.io/tech/sxchnge/notifications/app"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func main() {
|
|
path := flag.String("config.file", "config.yml", "notification configuration")
|
|
flag.Parse()
|
|
logger, err := zap.NewProduction()
|
|
if err != nil {
|
|
os.Exit(1)
|
|
}
|
|
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
|
defer cancel()
|
|
config, err := app.Load(*path)
|
|
if err == nil {
|
|
err = app.Run(ctx, config, logger)
|
|
}
|
|
if err != nil {
|
|
logger.Error("Notifications service terminated", zap.Error(err))
|
|
_ = logger.Sync()
|
|
os.Exit(1)
|
|
}
|
|
_ = logger.Sync()
|
|
}
|