mirror of
https://github.com/containers/podman.git
synced 2025-06-21 01:19:15 +08:00
Merge pull request #5901 from jwhonce/wip/service
V2 Remove existing unix domain socket on startup
This commit is contained in:
@ -2,8 +2,10 @@ package system
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/libpod/cmd/podman/registry"
|
"github.com/containers/libpod/cmd/podman/registry"
|
||||||
@ -59,6 +61,23 @@ func service(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
logrus.Infof("using API endpoint: '%s'", apiURI)
|
logrus.Infof("using API endpoint: '%s'", apiURI)
|
||||||
|
|
||||||
|
// Clean up any old existing unix domain socket
|
||||||
|
if len(apiURI) > 0 {
|
||||||
|
uri, err := url.Parse(apiURI)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// socket activation uses a unix:// socket in the shipped unit files but apiURI is coded as "" at this layer.
|
||||||
|
if "unix" == uri.Scheme && !registry.IsRemote() {
|
||||||
|
if err := syscall.Unlink(uri.Path); err != nil && !os.IsNotExist(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
mask := syscall.Umask(0177)
|
||||||
|
defer syscall.Umask(mask)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
opts := entities.ServiceOptions{
|
opts := entities.ServiceOptions{
|
||||||
URI: apiURI,
|
URI: apiURI,
|
||||||
Timeout: time.Duration(srvArgs.Timeout) * time.Second,
|
Timeout: time.Duration(srvArgs.Timeout) * time.Second,
|
||||||
|
Reference in New Issue
Block a user