config: don't set ulimit on windows

Use existing file limit mechanism
This commit is contained in:
Brannon King 2021-10-01 11:22:07 -04:00
parent 07d25ba7ce
commit ba05456830
4 changed files with 13 additions and 25 deletions

View file

@ -6,6 +6,7 @@ import (
"github.com/btcsuite/btclog" "github.com/btcsuite/btclog"
"github.com/lbryio/lbcd/claimtrie/config" "github.com/lbryio/lbcd/claimtrie/config"
"github.com/lbryio/lbcd/claimtrie/param" "github.com/lbryio/lbcd/claimtrie/param"
"github.com/lbryio/lbcd/limits"
"github.com/lbryio/lbcd/wire" "github.com/lbryio/lbcd/wire"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -51,5 +52,10 @@ func Execute() {
log = backendLogger.Logger("CMDL") log = backendLogger.Logger("CMDL")
log.SetLevel(btclog.LevelDebug) log.SetLevel(btclog.LevelDebug)
// Up some limits.
if err := limits.SetLimits(); err != nil {
log.Errorf("failed to set limits: %v\n", err)
}
rootCmd.Execute() // nolint : errchk rootCmd.Execute() // nolint : errchk
} }

View file

@ -31,7 +31,11 @@ func NewTemporalCommand() *cobra.Command {
return errors.Wrapf(err, "open temporal repo") return errors.Wrapf(err, "open temporal repo")
} }
for ht := fromHeight; ht < toHeight; ht++ { if toHeight <= 0 {
toHeight = fromHeight
}
for ht := fromHeight; ht <= toHeight; ht++ {
names, err := repo.NodesAt(ht) names, err := repo.NodesAt(ht)
if err != nil { if err != nil {
return errors.Wrapf(err, "get node names from temporal") return errors.Wrapf(err, "get node names from temporal")

View file

@ -2,33 +2,11 @@ package config
import ( import (
"path/filepath" "path/filepath"
"syscall"
"github.com/lbryio/lbcd/claimtrie/param" "github.com/lbryio/lbcd/claimtrie/param"
btcutil "github.com/lbryio/lbcutil" btcutil "github.com/lbryio/lbcutil"
) )
func init() {
// ensure that we have enough file handles
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
panic("Error getting File Handle RLimit: " + err.Error())
}
minRequiredFileHandles := uint64(24000) // seven databases and they each require ~2000, plus a few more to be safe
if rLimit.Max < minRequiredFileHandles {
panic("Error increasing File Handle RLimit: increasing file handle limit requires " +
"unavailable privileges. Allow at least 24000 handles.")
}
if rLimit.Cur < minRequiredFileHandles {
rLimit.Cur = minRequiredFileHandles
err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
panic("Error setting File Handle RLimit to 24000: " + err.Error())
}
}
}
var DefaultConfig = Config{ var DefaultConfig = Config{
Params: param.MainNet, Params: param.MainNet,

View file

@ -13,8 +13,8 @@ import (
) )
const ( const (
fileLimitWant = 2048 fileLimitWant = 2048 * 12
fileLimitMin = 1024 fileLimitMin = 2048 * 8
) )
// SetLimits raises some process limits to values which allow btcd and // SetLimits raises some process limits to values which allow btcd and