-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.go
48 lines (37 loc) · 781 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 (
"flag"
"io/ioutil"
"log"
"os"
"gopkg.in/yaml.v2"
)
func main() {
var c string
flag.StringVar(&c, "c", "app.yml", "config file path")
flag.Parse()
configOption, err := GetConfigOption(c)
if err != nil {
return
}
apple := NewApple(&AppleOption{
ConfigOption: configOption,
})
pid := os.Getpid()
log.Printf("[I] pid:%v", pid)
apple.Serve()
}
func GetConfigOption(c string) (*ConfigOption, error) {
configOption := &ConfigOption{}
data, err := ioutil.ReadFile(c)
if err != nil {
log.Printf("[E] read config failed. file:%v, err:%v", c, err)
return nil, err
}
err = yaml.Unmarshal(data, configOption)
if err != nil {
log.Printf("[E] unmarshal config failed. err:%v", err)
return nil, err
}
return configOption, nil
}