forked from broderickhyman/albiondata-client
-
Notifications
You must be signed in to change notification settings - Fork 1
/
albiondata-client.go
66 lines (54 loc) · 1.21 KB
/
albiondata-client.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
package main
import (
"os"
"strings"
"time"
"github.com/ao-data/albiondata-client/client"
"github.com/ao-data/albiondata-client/log"
"github.com/ao-data/albiondata-client/systray"
"github.com/ao-data/go-githubupdate/updater"
)
var version string
func init() {
client.ConfigGlobal.SetupFlags()
}
func main() {
if client.ConfigGlobal.PrintVersion {
log.Infof("Albion Data Client, version: %s", version)
return
}
startUpdater()
go systray.Run()
c := client.NewClient(version)
err := c.Run()
if err != nil {
log.Error(err)
log.Error("The program encountered an error. Press any key to close this window.")
var b = make([]byte, 1)
_, _ = os.Stdin.Read(b)
}
}
func startUpdater() {
if version != "" && !strings.Contains(version, "dev") {
u := updater.NewUpdater(
version,
"ao-data",
"albiondata-client",
"update-",
)
go func() {
maxTries := 2
for i := 0; i < maxTries; i++ {
err := u.BackgroundUpdater()
if err != nil {
log.Error(err.Error())
log.Info("Will try again in 60 seconds. You may need to run the client as Administrator.")
// Sleep and hope the network connects
time.Sleep(time.Second * 60)
} else {
break
}
}
}()
}
}