sectorstorage: wire up closing logic

This commit is contained in:
Łukasz Magiera
2020-03-25 00:52:55 +01:00
parent ecf53f88ce
commit cfc65f525a
7 changed files with 56 additions and 11 deletions
+16 -1
View File
@@ -342,5 +342,20 @@ func RetrievalProvider(h host.Host, miner *storage.Miner, sealer sectorstorage.S
func SectorStorage(mctx helpers.MetricsCtx, lc fx.Lifecycle, ls stores.LocalStorage, si stores.SectorIndex, cfg *sectorbuilder.Config, sc config.Storage, urls sectorstorage.URLs, ca lapi.Common) (*sectorstorage.Manager, error) {
ctx := helpers.LifecycleCtx(mctx, lc)
return sectorstorage.New(ctx, ls, si, cfg, sc, urls, ca)
sst, err := sectorstorage.New(ctx, ls, si, cfg, sc, urls, ca)
if err != nil {
return nil, err
}
lc.Append(fx.Hook{
OnStop: func(_ context.Context) error {
if err := sst.Close(); err != nil {
log.Errorf("%+v", err)
}
return nil
},
})
return sst, nil
}