-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (37 loc) · 983 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
43
44
45
46
47
48
package main
import (
"context"
"fmt"
"os"
"syscall"
"github.com/nixys/nxs-rbac-operator/ctx"
"github.com/nixys/nxs-rbac-operator/routines/access"
appctx "github.com/nixys/nxs-go-appctx/v2"
_ "github.com/go-sql-driver/mysql"
"github.com/sirupsen/logrus"
)
func main() {
// Read command line arguments
args := ctx.ArgsRead()
// Init appctx
appCtx, err := appctx.ContextInit(appctx.Settings{
CustomContext: &ctx.Ctx{},
Args: &args,
CfgPath: args.ConfigPath,
TermSignals: []os.Signal{syscall.SIGTERM, syscall.SIGINT},
ReloadSignals: []os.Signal{syscall.SIGHUP},
LogrotateSignals: []os.Signal{syscall.SIGUSR1},
LogFormatter: &logrus.JSONFormatter{},
})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
appCtx.Log().Info("program started")
// main() body function
defer appCtx.MainBodyGeneric()
// Create main context
c := context.Background()
// Create access
appCtx.RoutineCreate(c, access.Runtime)
}