config: don't set ulimit on windows
Use existing file limit mechanism
This commit is contained in:
parent
07d25ba7ce
commit
ba05456830
4 changed files with 13 additions and 25 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/btcsuite/btclog"
|
||||
"github.com/lbryio/lbcd/claimtrie/config"
|
||||
"github.com/lbryio/lbcd/claimtrie/param"
|
||||
"github.com/lbryio/lbcd/limits"
|
||||
"github.com/lbryio/lbcd/wire"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -51,5 +52,10 @@ func Execute() {
|
|||
log = backendLogger.Logger("CMDL")
|
||||
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
|
||||
}
|
||||
|
|
|
@ -31,7 +31,11 @@ func NewTemporalCommand() *cobra.Command {
|
|||
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)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "get node names from temporal")
|
||||
|
|
|
@ -2,33 +2,11 @@ package config
|
|||
|
||||
import (
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
|
||||
"github.com/lbryio/lbcd/claimtrie/param"
|
||||
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{
|
||||
Params: param.MainNet,
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
fileLimitWant = 2048
|
||||
fileLimitMin = 1024
|
||||
fileLimitWant = 2048 * 12
|
||||
fileLimitMin = 2048 * 8
|
||||
)
|
||||
|
||||
// SetLimits raises some process limits to values which allow btcd and
|
||||
|
|
Loading…
Add table
Reference in a new issue