Skip to content

Commit

Permalink
create directory for unix socket
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmanuylov committed Dec 2, 2016
1 parent 0f460a8 commit 3364f3e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion jongleur/jongleur.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"io"
"log"
"net"
"os"
"path/filepath"
"strings"
"time"
)
Expand Down Expand Up @@ -52,7 +54,7 @@ func Run(config *Config, logger *log.Logger) error {
}
}()

listener, err := net.Listen(config.SplitNetAddr())
listener, err := config.listen()
if err != nil {
return err
}
Expand Down Expand Up @@ -131,3 +133,15 @@ func (config *Config) SplitNetAddr() (string, string) {
return config.Listen[:atPos], config.Listen[atPos + 1:]
}
}

func (config *Config) listen() (net.Listener, error) {
network, addr := config.SplitNetAddr()

if strings.HasPrefix(network, "unix") {
if err := os.MkdirAll(filepath.Dir(addr), 0755); err != nil {
return nil, err
}
}

return net.Listen(network, addr)
}

0 comments on commit 3364f3e

Please sign in to comment.