From d03071663f06934968d3c3d6bf96173567b33722 Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Wed, 29 Jan 2020 23:41:24 +0400 Subject: [PATCH] Fix output of build info on start --- cmd/dmsgpty/commands/root.go | 5 +++++ cmd/dmsgpty/dmsgpty.go | 7 ------- cmd/hypervisor/commands/root.go | 6 ++++++ cmd/hypervisor/hypervisor.go | 7 ------- cmd/setup-node/commands/root.go | 4 ++++ cmd/setup-node/setup-node.go | 7 ------- cmd/skywire-visor/commands/root.go | 4 ++++ cmd/skywire-visor/skywire-visor.go | 7 ------- 8 files changed, 19 insertions(+), 28 deletions(-) diff --git a/cmd/dmsgpty/commands/root.go b/cmd/dmsgpty/commands/root.go index 6f13031c3d..bdeafc9ad9 100644 --- a/cmd/dmsgpty/commands/root.go +++ b/cmd/dmsgpty/commands/root.go @@ -10,6 +10,7 @@ import ( "github.com/spf13/cobra" "github.com/SkycoinProject/skywire-mainnet/internal/skyenv" + "github.com/SkycoinProject/skywire-mainnet/pkg/buildinfo" "github.com/SkycoinProject/skywire-mainnet/pkg/dmsgpty" ) @@ -32,6 +33,10 @@ var rootCmd = &cobra.Command{ Use: "dmsgpty", Short: "Run commands over dmsg", PreRunE: func(*cobra.Command, []string) error { + if _, err := buildinfo.Get().WriteTo(log.Writer()); err != nil { + log.Printf("Failed to output build info: %v", err) + } + return readDstAddr() }, RunE: func(*cobra.Command, []string) error { diff --git a/cmd/dmsgpty/dmsgpty.go b/cmd/dmsgpty/dmsgpty.go index 8dc86470ae..83233da6c0 100644 --- a/cmd/dmsgpty/dmsgpty.go +++ b/cmd/dmsgpty/dmsgpty.go @@ -1,16 +1,9 @@ package main import ( - "log" - "github.com/SkycoinProject/skywire-mainnet/cmd/dmsgpty/commands" - "github.com/SkycoinProject/skywire-mainnet/pkg/buildinfo" ) func main() { - if _, err := buildinfo.Get().WriteTo(log.Writer()); err != nil { - log.Printf("Failed to output build info: %v", err) - } - commands.Execute() } diff --git a/cmd/hypervisor/commands/root.go b/cmd/hypervisor/commands/root.go index b80ebae8ce..804518da0f 100644 --- a/cmd/hypervisor/commands/root.go +++ b/cmd/hypervisor/commands/root.go @@ -3,6 +3,7 @@ package commands import ( "fmt" "net/http" + "os" "github.com/SkycoinProject/dmsg" "github.com/SkycoinProject/dmsg/disc" @@ -10,6 +11,7 @@ import ( "github.com/SkycoinProject/skycoin/src/util/logging" "github.com/spf13/cobra" + "github.com/SkycoinProject/skywire-mainnet/pkg/buildinfo" "github.com/SkycoinProject/skywire-mainnet/pkg/hypervisor" "github.com/SkycoinProject/skywire-mainnet/pkg/util/pathutil" ) @@ -43,6 +45,10 @@ var rootCmd = &cobra.Command{ Use: "hypervisor", Short: "Manages Skywire App Nodes", Run: func(_ *cobra.Command, args []string) { + if _, err := buildinfo.Get().WriteTo(os.Stdout); err != nil { + log.Printf("Failed to output build info: %v", err) + } + if configPath == "" { configPath = pathutil.FindConfigPath(args, -1, configEnv, pathutil.HypervisorDefaults()) } diff --git a/cmd/hypervisor/hypervisor.go b/cmd/hypervisor/hypervisor.go index bde7de2f64..d049201954 100644 --- a/cmd/hypervisor/hypervisor.go +++ b/cmd/hypervisor/hypervisor.go @@ -4,16 +4,9 @@ skywire hypervisor package main import ( - "log" - "github.com/SkycoinProject/skywire-mainnet/cmd/hypervisor/commands" - "github.com/SkycoinProject/skywire-mainnet/pkg/buildinfo" ) func main() { - if _, err := buildinfo.Get().WriteTo(log.Writer()); err != nil { - log.Printf("Failed to output build info: %v", err) - } - commands.Execute() } diff --git a/cmd/setup-node/commands/root.go b/cmd/setup-node/commands/root.go index e9e32cba23..e415346caa 100644 --- a/cmd/setup-node/commands/root.go +++ b/cmd/setup-node/commands/root.go @@ -14,6 +14,7 @@ import ( logrussyslog "github.com/sirupsen/logrus/hooks/syslog" "github.com/spf13/cobra" + "github.com/SkycoinProject/skywire-mainnet/pkg/buildinfo" "github.com/SkycoinProject/skywire-mainnet/pkg/metrics" "github.com/SkycoinProject/skywire-mainnet/pkg/setup" ) @@ -29,6 +30,9 @@ var rootCmd = &cobra.Command{ Use: "setup-node [config.json]", Short: "Route Setup Node for skywire", Run: func(_ *cobra.Command, args []string) { + if _, err := buildinfo.Get().WriteTo(log.Writer()); err != nil { + log.Printf("Failed to output build info: %v", err) + } logger := logging.MustGetLogger(tag) if syslogAddr != "" { diff --git a/cmd/setup-node/setup-node.go b/cmd/setup-node/setup-node.go index 0409703ffb..fbf1c7e2d7 100644 --- a/cmd/setup-node/setup-node.go +++ b/cmd/setup-node/setup-node.go @@ -1,16 +1,9 @@ package main import ( - "log" - "github.com/SkycoinProject/skywire-mainnet/cmd/setup-node/commands" - "github.com/SkycoinProject/skywire-mainnet/pkg/buildinfo" ) func main() { - if _, err := buildinfo.Get().WriteTo(log.Writer()); err != nil { - log.Printf("Failed to output build info: %v", err) - } - commands.Execute() } diff --git a/cmd/skywire-visor/commands/root.go b/cmd/skywire-visor/commands/root.go index 56a4ada41f..f8ef684bf9 100644 --- a/cmd/skywire-visor/commands/root.go +++ b/cmd/skywire-visor/commands/root.go @@ -59,6 +59,10 @@ var rootCmd = &cobra.Command{ Use: "skywire-visor [config-path]", Short: "Visor for skywire", Run: func(_ *cobra.Command, args []string) { + if _, err := buildinfo.Get().WriteTo(log.Writer()); err != nil { + log.Printf("Failed to output build info: %v", err) + } + cfg.args = args cfg.startProfiler(). diff --git a/cmd/skywire-visor/skywire-visor.go b/cmd/skywire-visor/skywire-visor.go index ec71526239..282da4c41f 100644 --- a/cmd/skywire-visor/skywire-visor.go +++ b/cmd/skywire-visor/skywire-visor.go @@ -4,16 +4,9 @@ skywire visor package main import ( - "log" - "github.com/SkycoinProject/skywire-mainnet/cmd/skywire-visor/commands" - "github.com/SkycoinProject/skywire-mainnet/pkg/buildinfo" ) func main() { - if _, err := buildinfo.Get().WriteTo(log.Writer()); err != nil { - log.Printf("Failed to output build info: %v", err) - } - commands.Execute() }