From 3e1b16ea99ddbc8b07e1464e442ef6fddf678b10 Mon Sep 17 00:00:00 2001 From: Alexander Leitner Date: Fri, 12 Oct 2018 14:04:16 -0400 Subject: [PATCH] Start redis (#470) * Start miniredis, repairer, and checker with captplanet --- cmd/captplanet/run.go | 25 ++++++++++++++++++++++--- cmd/captplanet/setup.go | 5 +++-- pkg/datarepair/repairer/config.go | 2 +- pkg/datarepair/repairer/repairer.go | 4 ++++ 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/cmd/captplanet/run.go b/cmd/captplanet/run.go index 903d789c9..c8c56edb9 100644 --- a/cmd/captplanet/run.go +++ b/cmd/captplanet/run.go @@ -10,6 +10,7 @@ import ( "github.com/spf13/cobra" + "github.com/alicebob/miniredis" "storj.io/storj/pkg/auth/grpcauth" "storj.io/storj/pkg/cfgstruct" "storj.io/storj/pkg/datarepair/checker" @@ -114,11 +115,29 @@ func cmdRun(cmd *cobra.Command, args []string) (err error) { grpcauth.NewAPIKeyInterceptor(), runCfg.Satellite.PointerDB, runCfg.Satellite.Kademlia, - // runCfg.Satellite.Checker, - // runCfg.Satellite.Repairer, - o) + o, + ) }() + // start Repair + m := miniredis.NewMiniRedis() + m.RequireAuth("abc123") + + if err = m.StartAddr(":6378"); err != nil { + errch <- err + } else { + defer m.Close() + + go func() { + errch <- runCfg.Satellite.Checker.Run(ctx, nil) + }() + + go func() { + errch <- runCfg.Satellite.Repairer.Run(ctx, nil) + }() + + } + // start s3 uplink go func() { _, _ = fmt.Printf("Starting s3-gateway on %s\nAccess key: %s\nSecret key: %s\n", diff --git a/cmd/captplanet/setup.go b/cmd/captplanet/setup.go index 87f3e6dba..eecc60eb3 100644 --- a/cmd/captplanet/setup.go +++ b/cmd/captplanet/setup.go @@ -112,8 +112,9 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) { startingPort := setupCfg.StartingPort overrides := map[string]interface{}{ - "satellite.identity.cert-path": setupCfg.HCIdentity.CertPath, - "satellite.identity.key-path": setupCfg.HCIdentity.KeyPath, + "satellite.repairer.queue-address": "redis://127.0.0.1:6378?db=1&password=abc123", + "satellite.identity.cert-path": setupCfg.HCIdentity.CertPath, + "satellite.identity.key-path": setupCfg.HCIdentity.KeyPath, "satellite.identity.address": joinHostPort( setupCfg.ListenHost, startingPort+1), "satellite.kademlia.todo-listen-addr": joinHostPort( diff --git a/pkg/datarepair/repairer/config.go b/pkg/datarepair/repairer/config.go index 87a7e8822..182454f81 100644 --- a/pkg/datarepair/repairer/config.go +++ b/pkg/datarepair/repairer/config.go @@ -14,7 +14,7 @@ import ( // Config contains configurable values for repairer type Config struct { - QueueAddress string `help:"data repair queue address" default:"redis://localhost:6379?db=5&password=123"` + QueueAddress string `help:"data repair queue address" default:"redis://localhost:6379?db=0&password=testpass"` MaxRepair int `help:"maximum segments that can be repaired concurrently" default:"100"` Interval time.Duration `help:"how frequently checker should audit segments" default:"3600s"` } diff --git a/pkg/datarepair/repairer/repairer.go b/pkg/datarepair/repairer/repairer.go index fccb39648..30322690f 100644 --- a/pkg/datarepair/repairer/repairer.go +++ b/pkg/datarepair/repairer/repairer.go @@ -9,6 +9,8 @@ import ( "sync" "time" + "go.uber.org/zap" + q "storj.io/storj/pkg/datarepair/queue" "storj.io/storj/pkg/pb" "storj.io/storj/pkg/utils" @@ -36,6 +38,8 @@ type repairer struct { // Run the repairer loop func (r *repairer) Run() (err error) { + zap.S().Info("Repairer is starting up") + c := make(chan *pb.InjuredSegment) ticker := time.NewTicker(r.interval)