-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathmain.go
47 lines (42 loc) · 1.1 KB
/
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
// Copyright 2018 cloudy [email protected]. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package main
import (
"flag"
"fmt"
"github.com/itcloudy/base-framework/common"
"github.com/itcloudy/base-framework/router"
"github.com/itcloudy/base-framework/system"
"os"
"path"
)
func main() {
var err error
fPath, _ := os.Getwd()
fPath = path.Join(fPath, "conf")
configPath := flag.String("c", fPath, "config file path")
flag.Parse()
err = system.LoadConfigInformation(*configPath)
if err != nil {
return
}
//router init
router := router.InitRouter()
server := common.ServerInfo
serverInfo := common.StringsJoin(server.Host, ":", server.Port)
// restart
if server.EnableHttps {
fmt.Println("server start https")
err := router.RunTLS(serverInfo, server.CertFile, server.KeyFile)
if err != nil {
fmt.Println("server start failed ", err.Error())
}
} else {
fmt.Printf("server start info: %s\n", serverInfo)
err := router.Run(serverInfo)
if err != nil {
fmt.Println("server start failed ", err.Error())
}
}
}