-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
52 lines (41 loc) · 1.03 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
package main
import (
"fmt"
_ "raven/database"
"raven/models"
_ "raven/routers"
"github.com/beego/beego/v2/client/orm"
beego "github.com/beego/beego/v2/server/web"
_ "github.com/mattn/go-sqlite3"
)
func main() {
// Get the database name from the config
dbName, err := beego.AppConfig.String("dbname")
if err != nil {
panic(fmt.Errorf("failed to get dbname: %v", err))
}
// Start the database
force, verbose := false, true
err = orm.RunSyncdb(dbName, force, verbose)
if err != nil {
panic(err)
}
// Initialize the JWT cookie signing key
jwtSecret, _ := models.GetConfig("jwt_secret")
if jwtSecret.Value == "" {
models.InitializeJwtSecret()
}
// Initialize the server password
password, _ := models.GetConfig("password")
if password.Value == "" {
err := models.InitializePassword()
password, _ = models.GetConfig("password")
if err != nil {
panic(err)
}
}
fmt.Println("Server Password:", password.Value)
// Register time template function
beego.AddFuncMap("formatTime", models.FormatTime)
beego.Run()
}