Skip to content

Commit

Permalink
Merge branch 'mainnet-milestone1' into feature/226-manaager-node-back…
Browse files Browse the repository at this point in the history
…end-additions
  • Loading branch information
ivcosla committed Aug 27, 2019
2 parents d3ce2af + f261a1e commit c11437e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
10 changes: 7 additions & 3 deletions cmd/hypervisor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const configEnv = "SW_HYPERVISOR_CONFIG"
var (
log = logging.MustGetLogger("hypervisor")

configPath string
mock bool
mockEnableAuth bool
mockNodes int
Expand All @@ -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")
Expand All @@ -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()
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down
7 changes: 1 addition & 6 deletions pkg/setup/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion pkg/util/pathutil/configpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c11437e

Please sign in to comment.