Open jmgurney opened 4 years ago
I cannot reproduce by stopping ipfs normally. The file stays behind only when -KILLing ipfs.
Would you like to submit a patch to remove the unix socket on boot? Probably affects cmd/ipfs/daemon.go
(serveHTTPApi
).
(This snippet might be useful) https://github.com/djdv/go-ipfs/blob/6f22508188cc19132a08523488cc6d3e4f8047aa/plugin/plugins/filesystem/plugin.go#L127-L153
Edit: I've since modified this, looks like my most recent version is:
// maybeRemoveUnixSockets attempts to remove all Unix domain socket paths in a given multiaddr.
// It returns all errors encountered (wrapped), excluding all "not exist" errors.
func maybeRemoveUnixSockets(ma multiaddr.Multiaddr) (err error) {
multiaddr.ForEach(ma, func(comp multiaddr.Component) bool {
if comp.Protocol().Code == multiaddr.P_UNIX {
localPath := comp.Value()
if runtime.GOOS == "windows" { // `/C:\path` -> `C:\path`
localPath = strings.TrimPrefix(localPath, `/`)
}
osErr := os.Remove(localPath)
if osErr != nil && !os.IsNotExist(osErr) {
err = maybeWrapErr(err, osErr)
}
}
return false
})
return
}
Hey @hsanjuan , what's a safe way to kill ipfs if I'm backgrounding the daemon? -15 doesn't seem to impact the running daemon.
@NorseGaud please ask on https://discuss.ipfs.io.
When using a unix domain socket, config: "API": [ "/ip4/127.0.0.1/tcp/5001", "/unix/var/db/ipfs-go/socket/api.sock" ],
the first time it starts up, it works fine, but the second time it fails:
It is common for programs to either use a lock file, or just simply remove it on start.
I've worked around the issue by removing it in my startup file, but a better solution that is more generic would be nice.