-
Notifications
You must be signed in to change notification settings - Fork 0
/
console.go
44 lines (38 loc) · 887 Bytes
/
console.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
// Copyright 2020 The GoSchedule Authors. All rights reserved.
// Use of this source code is governed by BSD
// license that can be found in the LICENSE file.
package main
import (
"flag"
"os"
"path/filepath"
"strconv"
"github.com/gin-gonic/gin"
"github.com/jasonjoo2010/goschedule-console/app"
)
var (
configFile string
listenPort int
debug bool
)
func init() {
flag.StringVar(&configFile, "c", "config.yml", "Configuration file")
flag.IntVar(&listenPort, "p", 8000, "Serving port")
flag.BoolVar(&debug, "v", false, "Debug mode")
flag.Parse()
}
func main() {
baseDir, _ := filepath.Abs(filepath.Dir(os.Args[0]))
os.Chdir(baseDir)
err := app.Instance().InitConfig(configFile)
if err != nil {
return
}
if debug {
gin.SetMode(gin.DebugMode)
} else {
gin.SetMode(gin.ReleaseMode)
}
engine := InitEngine()
engine.Run(":" + strconv.Itoa(listenPort))
}