forked from cgs0730/hcc-violin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
52 lines (45 loc) · 888 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
49
50
51
52
package main
import (
"hcc/violin/action/graphql"
"hcc/violin/action/rabbitmq"
"hcc/violin/lib/config"
"hcc/violin/lib/logger"
"hcc/violin/lib/mysql"
"hcc/violin/lib/syscheck"
"net/http"
"strconv"
)
func init() {
err := syscheck.CheckRoot()
if err != nil {
panic(err)
}
err = logger.Init()
if err != nil {
panic(err)
}
config.Init()
err = mysql.Init()
if err != nil {
panic(err)
}
err = rabbitmq.Init()
if err != nil {
panic(err)
}
}
func main() {
defer func() {
rabbitmq.End()
mysql.End()
logger.End()
}()
http.Handle("/graphql", graphql.GraphqlHandler)
logger.Logger.Println("Opening server on port " + strconv.Itoa(int(config.HTTP.Port)) + "...")
err := http.ListenAndServe(":"+strconv.Itoa(int(config.HTTP.Port)), nil)
if err != nil {
logger.Logger.Println(err)
logger.Logger.Println("Failed to prepare http server!")
return
}
}