Fix UNIX socket support.
This commit is contained in:
parent
a29e6f1cd6
commit
fce0e42307
|
@ -8,7 +8,8 @@ name: Test
|
|||
address: "[::]"
|
||||
port: 5000
|
||||
|
||||
# Alternatively, lurkcoin can bind on a UNIX domain socket.
|
||||
# Alternatively, lurkcoin can bind on a UNIX domain socket. The socket will be
|
||||
# world-writable.
|
||||
# network_protocol: unix
|
||||
# address: "/tmp/lurkcoin.sock"
|
||||
|
||||
|
|
|
@ -151,6 +151,11 @@ func StartServer(config *Config) {
|
|||
log.Printf("Starting server on http://%s/", urlAddress)
|
||||
}
|
||||
|
||||
// Remove any socket file that already exists
|
||||
if networkProtocol == "unix" {
|
||||
os.Remove(address)
|
||||
}
|
||||
|
||||
// Bind to the address
|
||||
var ln net.Listener
|
||||
ln, err = net.Listen(networkProtocol, address)
|
||||
|
@ -158,6 +163,13 @@ func StartServer(config *Config) {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Change permissions on the UNIX socket
|
||||
if networkProtocol == "unix" {
|
||||
if err := os.Chmod(address, 0777); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Switch to the logfile
|
||||
if config.Logfile != "" {
|
||||
f, err := os.OpenFile(
|
||||
|
|
Loading…
Reference in New Issue