-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
34 lines (32 loc) · 797 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"context"
"github.com/kelseyhightower/envconfig"
"go.uber.org/zap"
"google-calendar-to-notion/app"
"log"
"os/signal"
"syscall"
)
func main() {
var config app.Config
if err := envconfig.Process("", &config); err != nil {
log.Fatal(err)
}
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer cancel()
logger, cleanupLogger, err := app.InitLogger(&config)
if err != nil {
log.Panic(err)
}
defer cleanupLogger()
logger.Info("initalizing", zap.Any("config", &config))
app, cleanupApp, err := app.InitApp(ctx, logger, &config)
if err != nil {
logger.Panic("failed to initialize", zap.Error(err))
}
defer cleanupApp()
if err := app.Run(ctx); err != nil {
logger.Error("failed to run", zap.Error(err))
}
}