diff --git a/cmd/skywire-visor/commands/root.go b/cmd/skywire-visor/commands/root.go index ed47be729..83feb1da1 100644 --- a/cmd/skywire-visor/commands/root.go +++ b/cmd/skywire-visor/commands/root.go @@ -171,6 +171,16 @@ func (cfg *runCfg) runNode() *runCfg { cfg.logger.Fatal("Failed to initialize node: ", err) } + if cfg.conf.DmsgPty != nil { + err = node.UnlinkSocketFiles(cfg.conf.AppServerSockFile, cfg.conf.DmsgPty.CLIAddr) + } else { + err = node.UnlinkSocketFiles(cfg.conf.AppServerSockFile) + } + + if err != nil { + cfg.logger.Fatal("failed to unlink socket files: ", err) + } + if cfg.conf.Uptime.Tracker != "" { uptimeTracker, err := utclient.NewHTTP(cfg.conf.Uptime.Tracker, cfg.conf.Node.StaticPubKey, cfg.conf.Node.StaticSecKey) if err != nil { diff --git a/pkg/visor/visor.go b/pkg/visor/visor.go index 114c26c92..9ca6e6a23 100644 --- a/pkg/visor/visor.go +++ b/pkg/visor/visor.go @@ -361,6 +361,13 @@ func (node *Node) Close() (err error) { } else { node.logger.Info("router stopped successfully") } + + if err := node.UnlinkSocketFiles(node.conf.AppServerSockFile); err != nil { + node.logger.WithError(err).Errorf("Failed to unlink socket file %s", node.conf.AppServerSockFile) + } else { + node.logger.Infof("Socket file %s removed successfully", node.conf.AppServerSockFile) + } + return err } @@ -496,3 +503,18 @@ func (node *Node) SetAutoStart(appName string, autoStart bool) error { node.appsConf[appName] = appConf return nil } + +// UnlinkSocketFiles removes unix socketFiles from file system +func (node *Node) UnlinkSocketFiles(socketFiles ...string) error { + for _, f := range socketFiles { + if err := syscall.Unlink(f); err != nil { + if strings.Contains(err.Error(), "no such file or directory") { + continue + } else { + return err + } + } + } + + return nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 831e5b965..e1f6cd45d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/SkycoinProject/dmsg v0.0.0-20191107094546-85c27858fca6 +# github.com/SkycoinProject/dmsg v0.0.0-20191107094546-85c27858fca6 => ../dmsg github.com/SkycoinProject/dmsg github.com/SkycoinProject/dmsg/cipher github.com/SkycoinProject/dmsg/disc