Support unix domain sockets.

This commit is contained in:
Sascha L. Teichmann 2017-03-05 14:03:02 +01:00
parent 349906c622
commit ba2dd15280
2 changed files with 19 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import (
"os" "os"
"os/signal" "os/signal"
"runtime" "runtime"
"strings"
"time" "time"
"bitbucket.org/s_l_teichmann/mtsatellite/common" "bitbucket.org/s_l_teichmann/mtsatellite/common"
@ -117,7 +118,14 @@ func main() {
var listener net.Listener var listener net.Listener
listener, err = net.Listen("tcp", fmt.Sprintf("%s:%d", host, port)) var proto, address string
if strings.ContainsRune(host, '/') {
proto, address = "unix", host
} else {
proto, address = "tcp", fmt.Sprintf("%s:%d", host, port)
}
listener, err = net.Listen(proto, address)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -10,6 +10,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
"strings"
"sync" "sync"
"bitbucket.org/s_l_teichmann/mtsatellite/common" "bitbucket.org/s_l_teichmann/mtsatellite/common"
@ -59,9 +60,17 @@ func createBaseLevel(
jobs := make(chan blockPos) jobs := make(chan blockPos)
var done sync.WaitGroup var done sync.WaitGroup
var proto string
if strings.ContainsRune(address, '/') {
proto = "unix"
} else {
proto = "tcp"
}
for i := 0; i < numWorkers; i++ { for i := 0; i < numWorkers; i++ {
var client *common.RedisClient var client *common.RedisClient
if client, err = common.NewRedisClient("tcp", address); err != nil {
if client, err = common.NewRedisClient(proto, address); err != nil {
return return
} }
done.Add(1) done.Add(1)