-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (28 loc) · 783 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
35
36
37
package main
import (
"context"
"flag"
"fmt"
"os"
"cloud.google.com/go/datastore"
"github.com/golang/glog"
"github.com/jchorl/watchdog/internal/email"
"github.com/jchorl/watchdog/pkg/server"
)
func main() {
flag.Set("logtostderr", "true") // for glog
flag.Parse()
ctx := context.Background()
emailClient := &email.Client{
SendGridAPIKey: sendGridAPIKey,
Domain: os.Getenv("DOMAIN"),
FromEmail: fmt.Sprintf("alerts@%s", os.Getenv("DOMAIN")),
ToEmail: os.Getenv("ALERT_EMAIL"),
}
datastoreClient, err := datastore.NewClient(ctx, os.Getenv("GOOGLE_CLOUD_PROJECT"))
if err != nil {
glog.Fatalf("creating db client: %+v", err)
}
srv := server.New(os.Getenv("PORT"), emailClient, datastoreClient)
glog.Error(srv.ListenAndServe())
}