-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
70 lines (60 loc) · 1.73 KB
/
main.go
File metadata and controls
70 lines (60 loc) · 1.73 KB
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
package main
import (
_ "embed"
"os"
"github.com/aide-family/magicbox/log"
"github.com/aide-family/magicbox/log/stdio"
"github.com/aide-family/magicbox/merr"
klog "github.com/go-kratos/kratos/v2/log"
"github.com/spf13/cobra"
"github.com/aide-family/marksman/cmd"
"github.com/aide-family/marksman/cmd/run"
"github.com/aide-family/marksman/cmd/run/all"
"github.com/aide-family/marksman/cmd/run/grpc"
"github.com/aide-family/marksman/cmd/run/http"
"github.com/aide-family/marksman/cmd/version"
)
var (
Name = "marksman"
Version = "latest"
BuildTime = "now"
Author = ""
Email = ""
Repo = "https://github.com/aide-family/marksman"
hostname, _ = os.Hostname()
)
//go:embed description.txt
var Description string
//go:embed config/server.yaml
var defaultServerConfig []byte
func init() {
cmd.SetGlobalFlags(
cmd.WithGlobalFlagsName(Name),
cmd.WithGlobalFlagsHostname(hostname),
cmd.WithGlobalFlagsVersion(Version),
cmd.WithGlobalFlagsBuildTime(BuildTime),
cmd.WithGlobalFlagsAuthor(Author),
cmd.WithGlobalFlagsEmail(Email),
cmd.WithGlobalFlagsREPO(Repo),
cmd.WithGlobalFlagsDescription(Description),
)
logger, err := log.NewLogger(stdio.LoggerDriver())
if err != nil {
panic(merr.ErrorInternalServer("new logger failed with error: %v", err).WithCause(err))
}
logger = klog.With(logger,
"ts", klog.DefaultTimestamp,
)
filterLogger := klog.NewFilter(logger, klog.FilterLevel(klog.LevelInfo))
helper := klog.NewHelper(filterLogger)
klog.SetLogger(helper.Logger())
}
func main() {
runCmd := run.NewCmd(defaultServerConfig)
runCmd.AddCommand(grpc.NewCmd(), http.NewCmd(), all.NewCmd())
children := []*cobra.Command{
version.NewCmd(),
runCmd,
}
cmd.Execute(cmd.NewCmd(), children...)
}