tordam

A library for peer discovery inside the Tor network
git clone https://git.parazyd.org/tordam
Log | Files | Refs | README | LICENSE

commit 2b894da7e0625dc4fccb811b001073c76c49019e
parent 5d78c9b02c3e25ca79d76d09ee6f08514946f402
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:
Mcmd/dam-dir/main.go | 18+++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/cmd/dam-dir/main.go b/cmd/dam-dir/main.go @@ -7,6 +7,7 @@ import ( "encoding/json" "log" "net/http" + "os/exec" "sync" "time" @@ -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) @@ -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)