From d8c8832a37f61f560d8aa2558a36fe6b1a80be14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 18 Mar 2020 05:40:25 +0100 Subject: [PATCH] stores: fix StorageList --- cmd/lotus-seal-worker/main.go | 20 +++++++++----------- storage/sealmgr/stores/index.go | 3 +++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cmd/lotus-seal-worker/main.go b/cmd/lotus-seal-worker/main.go index ba431f22e..8968abf40 100644 --- a/cmd/lotus-seal-worker/main.go +++ b/cmd/lotus-seal-worker/main.go @@ -7,9 +7,7 @@ import ( "net" "net/http" "os" - "os/signal" "path/filepath" - "syscall" "github.com/google/uuid" "github.com/gorilla/mux" @@ -117,11 +115,6 @@ var runCmd = &cli.Command{ } log.Infof("Remote version %s", v) - go func() { - <-ctx.Done() - log.Warn("Shutting down..") - }() - // Check params act, err := nodeApi.ActorAddress(ctx) @@ -202,6 +195,8 @@ var runCmd = &cli.Command{ return err } + log.Info("Connecting local storage to master") + if err := stores.DeclareLocalStorage( ctx, nodeApi, @@ -231,6 +226,8 @@ var runCmd = &cli.Command{ mux := mux.NewRouter() + log.Info("Setting up control endpoint at " + "http://" + cctx.String("address")) + rpcServer := jsonrpc.NewServer() rpcServer.Register("Filecoin", apistruct.PermissionedWorkerAPI(workerApi)) @@ -245,9 +242,8 @@ var runCmd = &cli.Command{ srv := &http.Server{Handler: ah} - sigChan := make(chan os.Signal, 2) go func() { - <-sigChan + <-ctx.Done() log.Warn("Shutting down..") if err := srv.Shutdown(context.TODO()); err != nil { log.Errorf("shutting down RPC server failed: %s", err) @@ -255,13 +251,15 @@ var runCmd = &cli.Command{ log.Warn("Graceful shutdown successful") }() - signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT) - nl, err := net.Listen("tcp4", cctx.String("address")) if err != nil { return err } + log.Info("Waiting for tasks") + + // todo go register + return srv.Serve(nl) }, } diff --git a/storage/sealmgr/stores/index.go b/storage/sealmgr/stores/index.go index df370741c..db4769989 100644 --- a/storage/sealmgr/stores/index.go +++ b/storage/sealmgr/stores/index.go @@ -67,6 +67,7 @@ func (i *Index) StorageList(ctx context.Context) (map[ID][]Decl, error) { out := map[ID][]Decl{} for id, m := range byID { + out[id] = []Decl{} for sectorID, fileType := range m { out[id] = append(out[id], Decl{ SectorID: sectorID, @@ -82,6 +83,8 @@ func (i *Index) StorageAttach(ctx context.Context, si StorageInfo) error { i.lk.Lock() defer i.lk.Unlock() + log.Infof("New sector storage: %s", si.ID) + if _, ok := i.stores[si.ID]; ok { for _, u := range si.URLs { if _, err := url.Parse(u); err != nil {