summaryrefslogtreecommitdiff
path: root/main.go
blob: 0346b42a40f8778f6b42433c8a5a91b3e6b9a5b1 (plain)
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
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0

package main

import (
	"os"
	"time"

	"go.wit.com/lib/config"
	"go.wit.com/lib/protobuf/argvpb"
	"go.wit.com/lib/protobuf/httppb"
	"go.wit.com/lib/protobuf/zoopb"
	"go.wit.com/log"
)

func main() {
	me = new(mainType)
	me.argv = argvpb.Autocomplete(&argv) // adds shell auto complete to go-args

	if argv.Daemon {
		// turn off timestamps for STDOUT (systemd adds them)
		log.DaemonMode(true)
	}

	me.hostname, _ = os.Hostname()
	me.pollDelay = time.Hour
	me.machines = zoopb.NewMachines()
	if err := config.ConfigLoad(me.machines, "zookeeper", "machine"); err != nil {
		badExit(err)
	}
	if argv.List != nil {
		log.Info("do list here")
		okExit("")
	}

	go NewWatchdog()
	if !argv.NoPort {
		go httppb.StartHTTP(okHandler, argv.Port)
	}

	me.myGui.Start() // loads the GUI toolkit
	doGui()          // start making our forge GUI

	// sit here forever refreshing the GUI
	for {
		refresh()
		time.Sleep(90 * time.Second)
	}
}