-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (33 loc) · 856 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
39
40
41
42
package main
import (
"log"
"os"
"github.com/kondohiroki/go-grpc-boilerplate/cmd"
"github.com/kondohiroki/go-grpc-boilerplate/internal/db/pgx"
"github.com/kondohiroki/go-grpc-boilerplate/internal/logger"
"go.uber.org/automaxprocs/maxprocs"
)
func main() {
defer func() {
_ = os.Remove("/tmp/live")
// Close the database connection pool
pgx.ClosePgxPool()
// Flush the log buffer
if logger.Log != nil {
logger.Log.Sync()
}
}()
// Liveness probe for Kubernetes
_, err := os.Create("/tmp/live")
if err != nil {
log.Fatalf("Cannot create a Liveness file: %v", err)
}
// Set the maximum number of CPUs to use
nopLog := func(string, ...interface{}) {}
_, err = maxprocs.Set(maxprocs.Logger(nopLog))
if err != nil {
log.Fatalf("Cannot set maxprocs: %v", err)
}
// Start the app here via CLI commands
cmd.Execute()
}