tStart redis if it's not already running on dam-dir startup. - tordam - A library for peer discovery inside the Tor network HTML git clone https://git.parazyd.org/tordam DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit 2b894da7e0625dc4fccb811b001073c76c49019e DIR parent 5d78c9b02c3e25ca79d76d09ee6f08514946f402 HTML Author: parazyd <parazyd@dyne.org> Date: Sat, 9 Dec 2017 18:38:37 +0100 Start redis if it's not already running on dam-dir startup. Diffstat: M cmd/dam-dir/main.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) --- DIR diff --git a/cmd/dam-dir/main.go b/cmd/dam-dir/main.go t@@ -7,6 +7,7 @@ import ( "encoding/json" "log" "net/http" + "os/exec" "sync" "time" t@@ -39,6 +40,18 @@ type nodeStruct struct { Valid int64 } +func startRedis() { + log.Println("Staring up redis-server...") + cmd := exec.Command("redis-server", "/usr/local/share/tor-dam/redis.conf") + err := cmd.Start() + lib.CheckError(err) + + time.Sleep(500 * time.Millisecond) + + _, err = RedisCli.Ping().Result() + lib.CheckError(err) +} + func handlePost(rw http.ResponseWriter, request *http.Request) { decoder := json.NewDecoder(request.Body) t@@ -169,7 +182,10 @@ func main() { var wg sync.WaitGroup _, err := RedisCli.Ping().Result() - lib.CheckError(err) + if err != nil { + // We assume redis is not running. Start it up. + startRedis() + } http.HandleFunc("/announce", handlePost)