Skip to content

Commit

Permalink
remove dmsgpty sock file
Browse files Browse the repository at this point in the history
  • Loading branch information
Kifen committed Jan 11, 2020
1 parent d7db1d6 commit d31d692
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
10 changes: 10 additions & 0 deletions cmd/skywire-visor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 22 additions & 0 deletions pkg/visor/visor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit d31d692

Please sign in to comment.