forked from omec-project/nrf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nrf.go
88 lines (74 loc) · 1.68 KB
/
nrf.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// SPDX-FileCopyrightText: 2021 Open Networking Foundation <[email protected]>
// Copyright 2019 free5GC.org
//
// SPDX-License-Identifier: Apache-2.0
/*
* API version: 1.0.0
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package main
import (
"fmt"
"os"
"runtime"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/omec-project/nrf/logger"
nrf_service "github.com/omec-project/nrf/service"
)
var NRF = &nrf_service.NRF{}
var appLog *logrus.Entry
func init() {
appLog = logger.AppLog
}
var (
VERSION string
BUILD_TIME string
COMMIT_HASH string
COMMIT_TIME string
)
func GetVersion() string {
if VERSION != "" {
return fmt.Sprintf(
"\n\tfree5GC version: %s"+
"\n\tbuild time: %s"+
"\n\tcommit hash: %s"+
"\n\tcommit time: %s"+
"\n\tgo version: %s %s/%s",
VERSION,
BUILD_TIME,
COMMIT_HASH,
COMMIT_TIME,
runtime.Version(),
runtime.GOOS,
runtime.GOARCH,
)
} else {
return fmt.Sprintf(
"\n\tNot specify ldflags (which link version) during go build\n\tgo version: %s %s/%s",
runtime.Version(),
runtime.GOOS,
runtime.GOARCH,
)
}
}
func main() {
app := cli.NewApp()
app.Name = "nrf"
fmt.Print(app.Name, "\n")
appLog.Infoln("NRF version: ", GetVersion())
app.Usage = "-free5gccfg common configuration file -nrfcfg nrf configuration file"
app.Action = action
app.Flags = NRF.GetCliCmd()
if err := app.Run(os.Args); err != nil {
appLog.Errorf("NRF Run Error: %v", err)
}
}
func action(c *cli.Context) error {
if err := NRF.Initialize(c); err != nil {
logger.CfgLog.Errorf("%+v", err)
return fmt.Errorf("Failed to initialize !!")
}
NRF.Start()
return nil
}