-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (31 loc) · 909 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
38
package main
import (
"context"
"fmt"
"os"
"runtime"
"github.com/andefined/flyinghorses/internal/services/monitor"
"github.com/andefined/flyinghorses/pkg/config"
"github.com/kelseyhightower/envconfig"
)
func main() {
// Create a new Config struct to store environment variables
cfg := config.NewConfig()
// Read config from env variables and panic on error,
// as we can't continue
err := envconfig.Process("", cfg)
if err != nil {
fmt.Printf("Failed to parse environment variables, exiting with error: %s\n", err.Error())
os.Exit(1)
}
// Set MAXPROCS
runtime.GOMAXPROCS(cfg.NumCPU)
// Create the context to cancel at exit
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Run the gRPC Server
if err := monitor.NewMonitorService(ctx, cfg); err != nil {
fmt.Printf("CellMonitorServive failure, exiting with error: %s\n", err.Error())
os.Exit(1)
}
}