-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.go
45 lines (40 loc) · 1.09 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
package main
import (
"fmt"
"github.com/algorandfoundation/nodekit/api"
"github.com/algorandfoundation/nodekit/cmd"
"github.com/charmbracelet/log"
"os"
"runtime"
)
var version = "dev"
func init() {
// TODO: handle log files
// Log as JSON instead of the default ASCII formatter.
//log.SetFormatter(log.JSONFormatter)
// Output to stdout instead of the default stderr
// Can be any io.Writer, see below for File example
log.SetOutput(os.Stdout)
// Only log the warning severity or above.
log.SetLevel(log.DebugLevel)
}
func main() {
var needsUpgrade = false
resp, err := api.GetNodeKitReleaseWithResponse(new(api.HttpPkg))
if err == nil && resp.ResponseCode >= 200 && resp.ResponseCode < 300 {
if resp.JSON200 != version {
needsUpgrade = true
// Warn on all commands but version
if len(os.Args) > 1 && os.Args[1] != "--version" {
log.Warn(
fmt.Sprintf("nodekit version v%s is available. Upgrade with \"nodekit upgrade\"", resp.JSON200))
}
}
}
// TODO: more performance tuning
runtime.GOMAXPROCS(1)
err = cmd.Execute(version, needsUpgrade)
if err != nil {
return
}
}