-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
94 lines (79 loc) · 2.12 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package main
import (
"os"
"github.com/astaxie/beego"
platformAuth "github.com/opensourceways/app-cla-server/code-platform-auth"
"github.com/opensourceways/app-cla-server/config"
"github.com/opensourceways/app-cla-server/controllers"
"github.com/opensourceways/app-cla-server/dbmodels"
"github.com/opensourceways/app-cla-server/email"
"github.com/opensourceways/app-cla-server/mongodb"
"github.com/opensourceways/app-cla-server/obs"
_ "github.com/opensourceways/app-cla-server/obs/huaweicloud"
"github.com/opensourceways/app-cla-server/pdf"
_ "github.com/opensourceways/app-cla-server/routers"
"github.com/opensourceways/app-cla-server/util"
"github.com/opensourceways/app-cla-server/worker"
)
func main() {
if beego.BConfig.RunMode == "dev" {
beego.BConfig.WebConfig.DirectoryIndex = true
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
}
if err := config.InitAppConfig(beego.AppConfig.String("app_conf")); err != nil {
beego.Error(err)
os.Exit(1)
}
AppConfig := config.AppConfig
path := util.GenFilePath(AppConfig.PDFOutDir, "tmp")
if util.IsNotDir(path) {
err := os.Mkdir(path, 0732)
if err != nil {
beego.Error(err)
os.Exit(1)
}
}
mongoClient, err := mongodb.Initialize(
&AppConfig.Mongodb,
AppConfig.SymmetricEncryptionKey,
AppConfig.SymmetricEncryptionNonce,
)
if err != nil {
beego.Error(err)
os.Exit(1)
}
obsClient, err := obs.Initialize(AppConfig.OBS)
if err != nil {
beego.Error(err)
os.Exit(1)
}
dbmodels.RegisterDB(struct {
dbmodels.IModel
dbmodels.IFile
}{
IModel: mongoClient,
IFile: obs.NewFileStorage(obsClient),
})
if err = email.Initialize(AppConfig.EmailPlatformConfigFile); err != nil {
beego.Error(err)
os.Exit(1)
}
if err := platformAuth.Initialize(AppConfig.CodePlatformConfigFile); err != nil {
beego.Error(err)
os.Exit(1)
}
if err := pdf.InitPDFGenerator(
AppConfig.PythonBin,
AppConfig.PDFOutDir,
AppConfig.PDFOrgSignatureDir,
); err != nil {
beego.Error(err)
os.Exit(1)
}
worker.InitEmailWorker(pdf.GetPDFGenerator())
if err := controllers.LoadLinks(); err != nil {
beego.Error(err)
os.Exit(1)
}
beego.Run()
}