-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
55 lines (47 loc) · 950 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
53
54
55
package main
import (
"flag"
"fmt"
"os"
log "github.com/sirupsen/logrus"
"work_server/controller"
_ "work_server/dao"
"work_server/router"
"work_server/util"
)
func init() {
util.CheckDir("./work/")
util.CheckDir("./db/")
_, err := os.Stat("./db/data.db")
if err != nil {
_, err := os.Create("./db/data.db")
if err != nil {
return
}
return
}
}
var (
token string
port int
ssl bool
)
func init() {
flag.StringVar(&token, "t", "qqewqeqdadadadd", "set a token")
flag.IntVar(&port, "p", 8085, "set port")
flag.BoolVar(&ssl, "ssl", false, "use a ssl")
flag.Parse()
controller.SetToken(token)
router.SetToken(token)
}
func main() {
if ssl {
if err := router.InitRouter().RunTLS(fmt.Sprintf("0.0.0.0:%d", port), "key.pem", "key.key"); err != nil {
log.Panicln(err.Error())
}
} else {
if err := router.InitRouter().Run(fmt.Sprintf("0.0.0.0:%d", port)); err != nil {
log.Panicln(err.Error())
}
}
}