diff --git a/cmd/hypervisor/commands/root.go b/cmd/hypervisor/commands/root.go index 2e77d36837..c15fd83e1a 100644 --- a/cmd/hypervisor/commands/root.go +++ b/cmd/hypervisor/commands/root.go @@ -18,6 +18,7 @@ const configEnv = "SW_HYPERVISOR_CONFIG" var ( log = logging.MustGetLogger("hypervisor") + configPath string mock bool mockEnableAuth bool mockNodes int @@ -26,6 +27,7 @@ var ( ) func init() { + rootCmd.Flags().StringVarP(&configPath, "config", "c", "./hypervisor-config.json", "hypervisor config path") rootCmd.Flags().BoolVarP(&mock, "mock", "m", false, "whether to run hypervisor with mock data") rootCmd.Flags().BoolVar(&mockEnableAuth, "mock-enable-auth", false, "whether to enable user management in mock mode") rootCmd.Flags().IntVar(&mockNodes, "mock-nodes", 5, "number of app nodes to have in mock mode") @@ -34,10 +36,12 @@ func init() { } var rootCmd = &cobra.Command{ - Use: "hypervisor [config-path]", + Use: "hypervisor", Short: "Manages Skywire App Nodes", Run: func(_ *cobra.Command, args []string) { - configPath := pathutil.FindConfigPath(args, 0, configEnv, pathutil.HypervisorDefaults()) + if configPath == "" { + configPath = pathutil.FindConfigPath(args, -1, configEnv, pathutil.HypervisorDefaults()) + } var config hypervisor.Config config.FillDefaults() @@ -56,7 +60,7 @@ var rootCmd = &cobra.Command{ log.Fatalln("Failed to start hypervisor:", err) } - log.Infof("serving RPC on '%s'", rpcAddr) + log.Infof("serving RPC on '%s'", rpcAddr) go func() { l, err := net.Listen("tcp", rpcAddr) if err != nil { diff --git a/go.mod b/go.mod index 5e076c4c91..5007d51bfa 100644 --- a/go.mod +++ b/go.mod @@ -23,8 +23,8 @@ require ( go.etcd.io/bbolt v1.3.3 golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586 golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 - golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // indirect - golang.org/x/tools v0.0.0-20190821162956-65e3620a7ae7 // indirect + golang.org/x/sys v0.0.0-20190825160603-fb81701db80f // indirect + golang.org/x/tools v0.0.0-20190826060629-95c3470cfb70 // indirect ) // Uncomment for tests with alternate branches of 'dmsg' diff --git a/go.sum b/go.sum index 70e2ee4d7e..37c2698295 100644 --- a/go.sum +++ b/go.sum @@ -143,6 +143,7 @@ golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa h1:KIDDMLT1O0Nr7TSxp8xM5tJcd golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190825160603-fb81701db80f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -155,6 +156,8 @@ golang.org/x/tools v0.0.0-20190816200558-6889da9d5479 h1:lfN2PY/jymfnxkNHlbBF5Dw golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190821162956-65e3620a7ae7 h1:PVCvyir09Xgta5zksNZDkrL+eSm/Y+gQxRG3IfqNQ3A= golang.org/x/tools v0.0.0-20190821162956-65e3620a7ae7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190826060629-95c3470cfb70 h1:Cde4MUY6o3RgxpWu8/7xCjEW7SE22me73ix+NIXtV7s= +golang.org/x/tools v0.0.0-20190826060629-95c3470cfb70/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= diff --git a/pkg/setup/node.go b/pkg/setup/node.go index 71f990198b..e2a6c0aa66 100644 --- a/pkg/setup/node.go +++ b/pkg/setup/node.go @@ -70,12 +70,7 @@ func NewNode(conf *Config, metrics metrics.Recorder) (*Node, error) { // Serve starts transport listening loop. func (sn *Node) Serve(ctx context.Context) error { - if err := sn.dmsgC.InitiateServerConnections(ctx, sn.srvCount); err != nil { - return fmt.Errorf("messaging: %s", err) - } - sn.Logger.Info("Connected to messaging servers") - - sn.Logger.Info("Starting Setup Node") + sn.Logger.Info("serving setup node") for { conn, err := sn.dmsgL.AcceptTransport() diff --git a/pkg/util/pathutil/configpath.go b/pkg/util/pathutil/configpath.go index 591ba23da2..b55729c1a0 100644 --- a/pkg/util/pathutil/configpath.go +++ b/pkg/util/pathutil/configpath.go @@ -97,8 +97,9 @@ func HypervisorDefaults() ConfigPaths { // - From CLI argument. // - From ENV. // - From a list of default paths. +// If argsIndex < 0, searching from CLI arguments does not take place. func FindConfigPath(args []string, argsIndex int, env string, defaults ConfigPaths) string { - if len(args) > argsIndex { + if argsIndex >= 0 && len(args) > argsIndex { path := args[argsIndex] log.Infof("using args[%d] as config path: %s", argsIndex, path) return path