-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
46 lines (40 loc) · 821 Bytes
/
main.go
File metadata and controls
46 lines (40 loc) · 821 Bytes
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 main
import (
"log"
"statGet/cmd/api"
"statGet/cmd/config"
"statGet/cmd/stop"
"statGet/cmd/tConnector"
"sync"
)
var (
server api.StatisticServer
wg *sync.WaitGroup
)
func init() {
if err := config.LoadEnvFile(); err != nil {
log.Fatalf("No .env file found")
}
tConnector.DefConnInit(config.GetTAddr(), nil)
server = api.GetServer(config.GetSAddr(), tConnector.GetDefaultConnection())
wg = &sync.WaitGroup{}
stop.Bind()
}
func main() {
log.Println("Statistic server started")
defer func() {
log.Println("Statistic server stopped")
}()
defer wg.Wait()
defer tConnector.DefConnClose()
wg.Add(1)
go func() {
defer wg.Done()
if err := server.Start(); err != nil {
log.Printf("Error on server performing: %v\n", err)
stop.Stop()
}
}()
defer server.Stop()
stop.Wait()
}