-
Notifications
You must be signed in to change notification settings - Fork 1
/
sikong.go
50 lines (43 loc) · 1.17 KB
/
sikong.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
package main
import (
"encoding/json"
"flag"
"fmt"
"github.com/raomuyang/sikong-mq/skmq"
"github.com/raomuyang/sikong-mq/skmq/base"
"github.com/raomuyang/sikong-mq/skmq/process"
"net/http"
_ "net/http/pprof"
"os"
)
const DebugPort = 7185
func main() {
LoadConf()
go func() {
http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", DebugPort), nil)
}()
process.LoggerSetup(nil, skmq.Configuration.LogLevel)
skmq.OpenServer()
}
func LoadConf() {
confPath := flag.String("conf", base.DefaultConf,
"The path of queue config.")
dbConfPath := flag.String("dbconf", base.DefaultDBConf, "The path of redis config file")
flag.Parse()
err := base.UnmarshalJsonFile(skmq.Configuration, *confPath)
if err != nil {
fmt.Printf("Error configuration: %s\n", *confPath)
os.Exit(1)
}
res, _ := json.Marshal(skmq.Configuration)
fmt.Printf("config : %s\n", res)
err = base.UnmarshalJsonFile(skmq.DBConfiguration, *dbConfPath)
if err != nil {
fmt.Println("The redis configuration was not found, use default config:")
res, _ := json.Marshal(skmq.DBConfiguration)
fmt.Printf("%s\n", res)
} else {
res, _ := json.Marshal(skmq.DBConfiguration)
fmt.Printf("db config: %s\n", res)
}
}