-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
48 lines (37 loc) · 1017 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 (
"github.com/micro-community/micro-starter/config"
"github.com/micro-community/micro-starter/pubsub"
"github.com/micro/micro/v3/cmd"
"github.com/micro/micro/v3/service"
"github.com/micro/micro/v3/service/logger"
"github.com/urfave/cli/v2"
//load profile
"github.com/micro-community/micro-starter/profile"
)
func main() {
srv := service.New(
service.Name("micro-v3-starter"),
service.Version("latest"),
)
// add customer Flags
cmdFlags := []cli.Flag{
&cli.BoolFlag{
Name: "debug",
Usage: "run in debug mode",
EnvVars: []string{"MICRO_STARTER_DEBUG_MODE"},
Value: true,
},
}
cmdFlags = append(cmd.DefaultCmd.App().Flags, cmdFlags...)
cmdOption := cmd.Flags(cmdFlags...)
cmd.DefaultCmd.Init(cmdOption)
srv.Init()
config.LoadConfigWithDefault(nil)
profile.BuildingStartupService(srv, config.Default)
//handle pub/sub message
pubsub.RegisterSubscription(srv, config.Default.Pubsub)
if err := srv.Run(); err != nil {
logger.Fatal(err)
}
}