This repository has been archived by the owner on Jul 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
executable file
·81 lines (62 loc) · 1.61 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
package main
import (
"RDMS_Client/dbus"
"RDMS_Client/handler"
. "RDMS_Client/logging"
"RDMS_Client/rest"
"RDMS_Client/utils"
"github.com/joho/godotenv"
"time"
)
const SleepTime = 15 * time.Minute
func main() {
//TODO:Забить фиксированные адреса
err := godotenv.Load()
if err != nil {
Error.Println("Can't load env. ", err)
}
go dbus.StartServer()
//Проверка на инициализацию
if status, err := utils.CheckInitStatus(); !status {
Info.Println("Initialize on server. ")
response, err := rest.Initialize()
if err != nil {
Error.Println("Can't initialize. ", err)
return
}
err = utils.WritePersonalKey(response.Data.Personal_key)
if err != nil {
Error.Fatal("Can't Write key. ", err)
}
err = utils.ChangeInitStatus()
if err != nil {
Error.Fatal("Can't write init status. ", err)
}
Info.Println("Successfully registered on the server. ")
} else if err != nil {
Error.Fatal("Can't check init status. ", err)
} else {
Info.Println("Already registered. ")
}
for {
wa := &rest.WorkstationAgent
err := wa.Init()
if err != nil {
Error.Fatal("Can't init WorkstationAgent. ", err)
}
err = rest.SignIn()
if err != nil {
Error.Fatal("SignIn error. ", err)
}
Info.Println("Successfully logged in. ")
packages, err := rest.GetPackagesList()
if err != nil {
Warning.Println("There was an error getting the package list. ", err)
} else {
Info.Println("Package list received successfully. ")
}
handler.HandlePackages(packages)
Info.Println("Cycle is done. Wait 15 minutes. ")
time.Sleep(SleepTime)
}
}