Merge pull request #8390 from filecoin-project/feat/worker-ulimitn-check
feat: worker: check fd limit on startup
This commit is contained in:
commit
064c3d473c
@ -35,6 +35,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
||||||
"github.com/filecoin-project/lotus/lib/lotuslog"
|
"github.com/filecoin-project/lotus/lib/lotuslog"
|
||||||
|
"github.com/filecoin-project/lotus/lib/ulimit"
|
||||||
"github.com/filecoin-project/lotus/metrics"
|
"github.com/filecoin-project/lotus/metrics"
|
||||||
"github.com/filecoin-project/lotus/node/modules"
|
"github.com/filecoin-project/lotus/node/modules"
|
||||||
"github.com/filecoin-project/lotus/node/repo"
|
"github.com/filecoin-project/lotus/node/repo"
|
||||||
@ -227,12 +228,23 @@ var runCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
limit, _, err := ulimit.GetLimit()
|
||||||
|
switch {
|
||||||
|
case err == ulimit.ErrUnsupported:
|
||||||
|
log.Errorw("checking file descriptor limit failed", "error", err)
|
||||||
|
case err != nil:
|
||||||
|
return xerrors.Errorf("checking fd limit: %w", err)
|
||||||
|
default:
|
||||||
|
if limit < build.MinerFDLimit {
|
||||||
|
return xerrors.Errorf("soft file descriptor limit (ulimit -n) too low, want %d, current %d", build.MinerFDLimit, limit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Connect to storage-miner
|
// Connect to storage-miner
|
||||||
ctx := lcli.ReqContext(cctx)
|
ctx := lcli.ReqContext(cctx)
|
||||||
|
|
||||||
var nodeApi api.StorageMiner
|
var nodeApi api.StorageMiner
|
||||||
var closer func()
|
var closer func()
|
||||||
var err error
|
|
||||||
for {
|
for {
|
||||||
nodeApi, closer, err = lcli.GetStorageMinerAPI(cctx, cliutil.StorageMinerUseHttp)
|
nodeApi, closer, err = lcli.GetStorageMinerAPI(cctx, cliutil.StorageMinerUseHttp)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user