-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
79 lines (66 loc) · 1.21 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
package main
import (
"context"
"runtime"
"time"
"github.com/alpine-client/pinnacle/sentry"
"github.com/alpine-client/pinnacle/ui"
)
var version string
func main() {
p := &Pinnacle{
os: OperatingSystem(runtime.GOOS),
arch: Architecture(runtime.GOARCH),
version: version,
}
if err := p.setup(); err != nil {
panic(err)
}
defer sentry.Flush(2 * time.Second)
p.Run()
}
func (p *Pinnacle) Run() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
if p.isUpdateAvailable(ctx) {
ui.NotifyNewUpdate()
}
done := make(chan bool)
defer close(done)
type task struct {
c context.Context
j func(context.Context) error
f func(context.Context, error) error
}
go func() {
for _, t := range []task{
{
c: sentry.NewContext(ctx, "java"),
j: p.checkJava,
f: p.download,
},
{
c: sentry.NewContext(ctx, "launcher"),
j: p.checkLauncher,
f: p.download,
},
{
c: sentry.NewContext(ctx, "start"),
j: p.startLauncher,
f: p.error,
},
} {
err := t.f(t.c, t.j(t.c))
if err != nil {
p.cleanup(t.c, err)
break
}
}
ui.Close()
done <- true
}()
<-done
if p.logFile != nil {
p.CaptureErr(ctx, p.logFile.Close())
}
}