89 lines
2.1 KiB
Go
89 lines
2.1 KiB
Go
package main
|
|
|
|
import "log"
|
|
import "os"
|
|
import "time"
|
|
// import "fmt"
|
|
|
|
import "github.com/gookit/config"
|
|
|
|
import "github.com/andlabs/ui"
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
import "git.wit.com/wit/gui"
|
|
|
|
// import "github.com/davecgh/go-spew/spew"
|
|
|
|
// reminder to use this for JSON
|
|
// https://github.com/tidwall/gjson
|
|
// value := gjson.Get(json, "name.last")
|
|
// println(value.String())
|
|
// value := gjson.Get(json, friends.#[last=="Murphy"].first)
|
|
|
|
// use mergo to merge structs
|
|
// import "github.com/imdario/mergo"
|
|
// mergo.Merge(&dest, src)
|
|
|
|
// always sorted slice (new project)
|
|
// https://github.com/yaa110/sslice
|
|
|
|
// several smart slice functions (new project. April 2019)
|
|
// https://github.com/elliotchance/pie
|
|
|
|
// Exit and write out the config
|
|
// (in yaml and json I guess.)
|
|
// switch to json once it can be made human readable
|
|
func onExit() {
|
|
log.Println("Sleep for 1 second")
|
|
time.Sleep(1 * 1000 * 1000 * 1000)
|
|
|
|
f, err := os.Create("/tmp/cloud-control-panel.yaml")
|
|
if err == nil {
|
|
config.DumpTo(f, "yaml")
|
|
}
|
|
|
|
f, err = os.Create("/tmp/cloud-control-panel.json")
|
|
if err == nil {
|
|
config.DumpTo(f, "json")
|
|
}
|
|
|
|
os.Exit(0)
|
|
}
|
|
|
|
func main() {
|
|
parseConfig()
|
|
|
|
// only test the socket code if no GUI
|
|
if (config.String("nogui") == "true") {
|
|
log.Println("Need to re-implement this")
|
|
onExit()
|
|
}
|
|
|
|
initChannel()
|
|
go processEvents()
|
|
|
|
go gorillaDial("v000185.testing.com.customers.wprod.wit.com:9000")
|
|
|
|
gui.Width = config.Int("width")
|
|
gui.Height = config.Int("height")
|
|
|
|
// make this the main loop in an attempt to figure out the crashes
|
|
// do not change this until the GUI is stable
|
|
ui.Main(setupCloudUI)
|
|
|
|
/*
|
|
for account, _ := range config.StringMap("cloud") {
|
|
port := config.String("cloud." + account + ".port")
|
|
proto := config.String("cloud." + account + ".proto")
|
|
hostname := config.String("cloud." + account + ".hostname")
|
|
rows := config.Int("cloud." + account + ".rows")
|
|
fmt.Println(hostname, port, proto, rows)
|
|
|
|
gui.AddTableTab(account, rows, parts)
|
|
|
|
log.Println("Sleep for 10 seconds, then add next table")
|
|
time.Sleep(10 * 1000 * 1000 * 1000)
|
|
}
|
|
*/
|
|
}
|