-
Notifications
You must be signed in to change notification settings - Fork 6
/
elaina.go
37 lines (29 loc) · 829 Bytes
/
elaina.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
package main
import (
"flag"
"github.com/sirupsen/logrus"
"github.com/wuhan005/Elaina/internal/config"
"github.com/wuhan005/Elaina/internal/db"
"github.com/wuhan005/Elaina/internal/route"
)
func main() {
port := flag.Int("port", 8080, "Web service port")
flag.Parse()
if err := config.Init(); err != nil {
logrus.WithError(err).Fatal("Failed to init config")
}
// Check environment config, make sure the application is safe enough.
appPassword := config.App.Password
if appPassword == "" || len(appPassword) < 8 {
logrus.Fatal("APP_PASSWORD is not strong enough")
}
dbInstance, err := db.Init()
if err != nil {
logrus.WithError(err).Fatal("Failed to connect to database")
}
r, err := route.New(dbInstance)
if err != nil {
logrus.WithError(err).Fatal("Failed to create route")
}
r.Run(*port)
}