-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrun.go
More file actions
36 lines (31 loc) · 674 Bytes
/
run.go
File metadata and controls
36 lines (31 loc) · 674 Bytes
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
package main
import (
"flag"
"fmt"
"moto/config"
"moto/controller"
"moto/utils"
"os"
"sync"
)
func main() {
conf := flag.String("config", "", "Path to config file")
flag.Parse()
// Load config if a path is provided; overrides default and env
if *conf != "" {
if err := config.Reload(*conf); err != nil {
fmt.Printf("failed to load config: %v\n", err)
os.Exit(1)
}
}
defer utils.Logger.Sync()
utils.Logger.Info("MOTO 启动...")
// single-sided build: no accelerator init required
wg := &sync.WaitGroup{}
for _, v := range config.GlobalCfg.Rules {
wg.Add(1)
go controller.Listen(v, wg)
}
wg.Wait()
utils.Logger.Info("MOTO 关闭...")
}