87 lines
1.9 KiB
Go
87 lines
1.9 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
|
|
|
|
// 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") {
|
|
retrySocket()
|
|
onExit()
|
|
}
|
|
|
|
initChannel()
|
|
go processEvents()
|
|
|
|
// setups up a dnssecsocket()
|
|
go retrySocket()
|
|
|
|
time.Sleep(3 * 1000 * 1000 * 1000)
|
|
go gorillaDial()
|
|
|
|
// 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)
|
|
}
|
|
*/
|
|
}
|