summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go36
1 files changed, 34 insertions, 2 deletions
diff --git a/main.go b/main.go
index 7c993cd..a72ef74 100644
--- a/main.go
+++ b/main.go
@@ -16,11 +16,15 @@ package main
import (
"embed"
- "flag"
"net"
+ "os"
+ "path/filepath"
"time"
"github.com/digitalocean/go-qemu/hypervisor"
+ "go.wit.com/dev/alexflint/arg"
+ pb "go.wit.com/lib/protobuf/virtbuf"
+ "go.wit.com/log"
)
var Version string
@@ -31,7 +35,35 @@ var resources embed.FS
var hv *hypervisor.Hypervisor
func main() {
- flag.Parse()
+ if os.Getenv("VIRTIGO_HOME") == "" {
+ homeDir, _ := os.UserHomeDir()
+ fullpath := filepath.Join(homeDir, ".config/virtigo")
+ os.Setenv("VIRTIGO_HOME", fullpath)
+ }
+ var pp *arg.Parser
+ pp = arg.MustParse(&argv)
+
+ if pp == nil {
+ pp.WriteHelp(os.Stdout)
+ os.Exit(0)
+ }
+
+ me.cluster = new(pb.Cluster)
+ if err := me.cluster.ConfigLoad(); err != nil {
+ log.Info("config file error:", err)
+ os.Exit(0)
+ }
+
+ for i, e := range me.cluster.Events {
+ log.Info("Event", i, e)
+ }
+
+ if argv.Start != "" {
+ newStart(argv.Start)
+ os.Exit(0)
+ }
+
+ log.DaemonMode(true)
// fmt.Printf("\nConnecting to %s://%s\n", *network, *address)
newConn := func() (net.Conn, error) {