stores: fix StorageList

This commit is contained in:
Łukasz Magiera 2020-03-18 05:40:25 +01:00
parent 5f2caffb51
commit d8c8832a37
2 changed files with 12 additions and 11 deletions

View File

@ -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)
},
}

View File

@ -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 {