diff --git a/cmd/apps/skychat/chat.go b/cmd/apps/skychat/chat.go index 4dfe3d76bc..31a4d25513 100644 --- a/cmd/apps/skychat/chat.go +++ b/cmd/apps/skychat/chat.go @@ -174,9 +174,11 @@ func messageHandler(w http.ResponseWriter, req *http.Request) { _, err := conn.Write([]byte(data["message"])) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) + connsMu.Lock() delete(chatConns, pk) connsMu.Unlock() + return } diff --git a/cmd/setup-node/commands/root.go b/cmd/setup-node/commands/root.go index a0ab28e8cf..2fe966d289 100644 --- a/cmd/setup-node/commands/root.go +++ b/cmd/setup-node/commands/root.go @@ -4,6 +4,7 @@ import ( "bufio" "encoding/json" "io" + "io/ioutil" "log" "log/syslog" "net/http" @@ -62,10 +63,18 @@ var rootCmd = &cobra.Command{ } conf := &setup.Config{} - if err := json.NewDecoder(rdr).Decode(&conf); err != nil { - log.Fatalf("Failed to decode %s: %s", rdr, err) + + raw, err := ioutil.ReadAll(rdr) + if err != nil { + logger.Fatalf("Failed to read config: %v", err) } + if err := json.Unmarshal(raw, &conf); err != nil { + logger.WithField("raw", string(raw)).Fatalf("Failed to decode config: %s", err) + } + + logger.Infof("Config: %#v", conf) + sn, err := setup.NewNode(conf, metrics.NewPrometheus("setupnode")) if err != nil { logger.Fatal("Failed to create a setup node: ", err) diff --git a/cmd/skywire-visor/commands/root.go b/cmd/skywire-visor/commands/root.go index 7d6e37c74e..1b689f8567 100644 --- a/cmd/skywire-visor/commands/root.go +++ b/cmd/skywire-visor/commands/root.go @@ -171,10 +171,17 @@ func (cfg *runCfg) readConfig() *runCfg { rdr = bufio.NewReader(os.Stdin) } - if err := json.NewDecoder(rdr).Decode(&cfg.conf); err != nil { - cfg.logger.Fatalf("Failed to decode %s: %s", rdr, err) + raw, err := ioutil.ReadAll(rdr) + if err != nil { + cfg.logger.Fatalf("Failed to read config: %v", err) + } + + if err := json.Unmarshal(raw, &cfg.conf); err != nil { + cfg.logger.WithField("raw", string(raw)).Fatalf("Failed to decode config: %s", err) } + cfg.logger.Infof("Config: %#v", &cfg.conf) + cfg.conf.Path = configPath return cfg diff --git a/pkg/visor/config.go b/pkg/visor/config.go index 5898717327..07d2e7f6e2 100644 --- a/pkg/visor/config.go +++ b/pkg/visor/config.go @@ -85,7 +85,7 @@ func (c *Config) flush() error { return ErrNoConfigPath } - c.log.Infof("Updating visor config to %+v", c) + c.log.Infof("Updating visor config to %#v", c) bytes, err := json.MarshalIndent(c, "", "\t") if err != nil {