-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
70 lines (59 loc) · 1.32 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"io"
"kanban/config"
"kanban/controllers"
"kanban/models"
"kanban/routers"
"os"
"os/user"
"github.com/gin-gonic/gin"
"github.com/mattn/go-colorable"
"github.com/sirupsen/logrus"
)
func main() {
user, err := user.Current()
if err != nil {
panic(err)
}
runmod := "prod"
configPath := "/config/config.json"
if user.Name != "root" {
configPath = "./config/config.json"
runmod = "dev"
} else {
gin.SetMode(gin.ReleaseMode)
gin.DefaultWriter = io.Discard
}
initLogger()
config.SetConfig("runmod", runmod)
config.SetConfig("configs", configPath)
config.LoadConfig(runmod)
models.SetDB(config.GetConnectionString())
models.User{}.Migrate()
models.Issue{}.Migrate()
models.Project{}.Migrate()
models.Comment{}.Migrate()
models.Issue{}.Migrate()
models.Notifications{}.Migrate()
models.ProjectUser{}.Migrate()
models.WorkSpace{}.Migrate()
controllers.LoadTemplates()
router := gin.Default()
routers.Load(router)
if err := router.Run(":8000"); err != nil {
logrus.Fatal(err)
os.Exit(1)
}
}
func initLogger() {
logrus.SetFormatter(&logrus.TextFormatter{
ForceColors: true,
FullTimestamp: true,
TimestampFormat: "2006-01-02 15:04:05",
})
logrus.SetOutput(colorable.NewColorableStdout())
if gin.Mode() == gin.DebugMode {
logrus.SetLevel(logrus.DebugLevel)
}
}