-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
45 lines (39 loc) · 1014 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
package main
import (
"fmt"
"github.com/gin-gonic/gin"
"net/http"
"os"
"showta.cc/app/system/conf"
"showta.cc/app/system/log"
"showta.cc/app/system/logic"
"showta.cc/app/system/model"
"showta.cc/app/system/router"
)
func main() {
conf.InitConf()
log.InitCore(conf.AppConf.Log)
model.InitDb(conf.AppConf.Database)
logic.Init()
gin.SetMode(gin.ReleaseMode)
routerInit := router.InitRouter()
endPoint := fmt.Sprintf("%s:%d", conf.AppConf.Server.Host, conf.AppConf.Server.Port)
server := &http.Server{
Addr: endPoint,
Handler: routerInit,
}
var err error
if conf.AppConf.Server.Https {
log.StdInfof("start https server listening %s", endPoint)
sslCertFile := conf.AbsPath(conf.AppConf.Server.SSLCertPem)
sslKeyFile := conf.AbsPath(conf.AppConf.Server.SSLKeyPem)
err = server.ListenAndServeTLS(sslCertFile, sslKeyFile)
} else {
log.StdInfof("start http server listening %s", endPoint)
err = server.ListenAndServe()
}
if err != nil {
log.StdError(err)
os.Exit(0)
}
}