stores: fix StorageList
This commit is contained in:
parent
5f2caffb51
commit
d8c8832a37
@ -7,9 +7,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
@ -117,11 +115,6 @@ var runCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
log.Infof("Remote version %s", v)
|
log.Infof("Remote version %s", v)
|
||||||
|
|
||||||
go func() {
|
|
||||||
<-ctx.Done()
|
|
||||||
log.Warn("Shutting down..")
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Check params
|
// Check params
|
||||||
|
|
||||||
act, err := nodeApi.ActorAddress(ctx)
|
act, err := nodeApi.ActorAddress(ctx)
|
||||||
@ -202,6 +195,8 @@ var runCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Info("Connecting local storage to master")
|
||||||
|
|
||||||
if err := stores.DeclareLocalStorage(
|
if err := stores.DeclareLocalStorage(
|
||||||
ctx,
|
ctx,
|
||||||
nodeApi,
|
nodeApi,
|
||||||
@ -231,6 +226,8 @@ var runCmd = &cli.Command{
|
|||||||
|
|
||||||
mux := mux.NewRouter()
|
mux := mux.NewRouter()
|
||||||
|
|
||||||
|
log.Info("Setting up control endpoint at " + "http://" + cctx.String("address"))
|
||||||
|
|
||||||
rpcServer := jsonrpc.NewServer()
|
rpcServer := jsonrpc.NewServer()
|
||||||
rpcServer.Register("Filecoin", apistruct.PermissionedWorkerAPI(workerApi))
|
rpcServer.Register("Filecoin", apistruct.PermissionedWorkerAPI(workerApi))
|
||||||
|
|
||||||
@ -245,9 +242,8 @@ var runCmd = &cli.Command{
|
|||||||
|
|
||||||
srv := &http.Server{Handler: ah}
|
srv := &http.Server{Handler: ah}
|
||||||
|
|
||||||
sigChan := make(chan os.Signal, 2)
|
|
||||||
go func() {
|
go func() {
|
||||||
<-sigChan
|
<-ctx.Done()
|
||||||
log.Warn("Shutting down..")
|
log.Warn("Shutting down..")
|
||||||
if err := srv.Shutdown(context.TODO()); err != nil {
|
if err := srv.Shutdown(context.TODO()); err != nil {
|
||||||
log.Errorf("shutting down RPC server failed: %s", err)
|
log.Errorf("shutting down RPC server failed: %s", err)
|
||||||
@ -255,13 +251,15 @@ var runCmd = &cli.Command{
|
|||||||
log.Warn("Graceful shutdown successful")
|
log.Warn("Graceful shutdown successful")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT)
|
|
||||||
|
|
||||||
nl, err := net.Listen("tcp4", cctx.String("address"))
|
nl, err := net.Listen("tcp4", cctx.String("address"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Info("Waiting for tasks")
|
||||||
|
|
||||||
|
// todo go register
|
||||||
|
|
||||||
return srv.Serve(nl)
|
return srv.Serve(nl)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ func (i *Index) StorageList(ctx context.Context) (map[ID][]Decl, error) {
|
|||||||
|
|
||||||
out := map[ID][]Decl{}
|
out := map[ID][]Decl{}
|
||||||
for id, m := range byID {
|
for id, m := range byID {
|
||||||
|
out[id] = []Decl{}
|
||||||
for sectorID, fileType := range m {
|
for sectorID, fileType := range m {
|
||||||
out[id] = append(out[id], Decl{
|
out[id] = append(out[id], Decl{
|
||||||
SectorID: sectorID,
|
SectorID: sectorID,
|
||||||
@ -82,6 +83,8 @@ func (i *Index) StorageAttach(ctx context.Context, si StorageInfo) error {
|
|||||||
i.lk.Lock()
|
i.lk.Lock()
|
||||||
defer i.lk.Unlock()
|
defer i.lk.Unlock()
|
||||||
|
|
||||||
|
log.Infof("New sector storage: %s", si.ID)
|
||||||
|
|
||||||
if _, ok := i.stores[si.ID]; ok {
|
if _, ok := i.stores[si.ID]; ok {
|
||||||
for _, u := range si.URLs {
|
for _, u := range si.URLs {
|
||||||
if _, err := url.Parse(u); err != nil {
|
if _, err := url.Parse(u); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user