/
start.go
56 lines (44 loc) · 1.22 KB
/
start.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
package cmd
import (
"fmt"
"github.com/bsinou/vitrnx-goback/auth"
"github.com/bsinou/vitrnx-goback/conf"
"github.com/bsinou/vitrnx-goback/gorm"
"github.com/bsinou/vitrnx-goback/mongodb"
"github.com/bsinou/vitrnx-goback/route"
"github.com/spf13/cobra"
)
var (
// wg sync.WaitGroup
)
// StartCmd represents the start command
var StartCmd = &cobra.Command{
Use: "start",
Short: "Start the VitrnX Backend",
Long: ``,
PreRun: func(cmd *cobra.Command, args []string) {
},
Run: func(cmd *cobra.Command, args []string) {
// Real start of the backend. Should be enhanced
ts := conf.BuildTimestamp
if ts == "" {
ts = "just now..."
} else {
ts = "on " + ts
}
cmd.Print(fmt.Sprintf("\n\n%s - Vitrnx Go Backend v%s (built %s)\n ==> Starting in %s mode.\n\n", conf.VitrnxInstanceID, conf.VitrnxVersion, ts, conf.Env))
// TODO Implement a better way to initialise services and manage clean shutdown
gorm.InitGormRepo()
// TODO enhance: launch a sync with firebase on each startup
// it is not too gravious this is reintrant
auth.ListExistingUsers(nil)
mongodb.InitMongoConnection()
// start gin router
route.StartRouter()
// wg.Add(1)
// wg.Wait()
},
}
func init() {
RootCmd.AddCommand(StartCmd)
}