/
starter.go
46 lines (38 loc) · 1.02 KB
/
starter.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
package app
import (
"context"
"fmt"
"sync"
"github.com/9sarkan/golang-base/config"
"github.com/9sarkan/golang-base/pkg/middlewares"
"github.com/9sarkan/golang-base/pkg/utils"
)
type App struct{}
// StartApplication function will start application and configure all dependencies
func (app App) StartApplication(dbg bool, cfgPath string) error {
config.Map.SetDebugMode(dbg)
if err := config.Map.LoadFromFile(cfgPath); err != nil {
return err
}
return app.StartServers()
}
// StartDatabases configure databases
func (app App) StartDatabases(cnf config.Database) error {
return nil
}
func (app App) StartServers() error {
// start grpc server
var wg sync.WaitGroup
rc := RouterCenter{}
wg.Add(1)
go func() {
if err := rc.InitialGrpcServer(context.Background(), config.Map.Service.GRPCServer, middlewares.GRPCAuth, utils.PanicRecover); err != nil {
// call service down notifiers
fmt.Printf("hello world")
utils.ServiceDownNotifier(err, "<internal grpc service>")
}
wg.Done()
}()
wg.Wait()
return nil
}