Increase default file limit on startup (#5436)

We use file descriptors for validators and sockets and might run out of
either on high-validator setups - increasing the limit here is harmless
and avoids a common limiting factor in setup

Co-authored-by: Etan Kissling <etan@status.im>
This commit is contained in:
Jacek Sieka 2023-09-21 16:08:13 +02:00 committed by GitHub
parent e7bc41e005
commit e64b31986e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 0 deletions

View File

@ -2171,6 +2171,7 @@ programMain:
# permissions are insecure.
quit QuitFailure
setupFileLimits()
setupLogging(config.logLevel, config.logStdout, config.logFile)
## This Ctrl+C handler exits the program in non-graceful way.

View File

@ -106,6 +106,17 @@ when defaultChroniclesStream.outputs.type.arity == 2:
from std/os import splitFile
from "."/filepath import secureCreatePath
proc setupFileLimits*() =
when not defined(windows):
# In addition to databases and sockets, we need a file descriptor for every
# validator - setting it to 16k should provide sufficient margin
let
limit = getMaxOpenFiles2().valueOr(16384)
if limit < 16384:
setMaxOpenFiles2(16384).isOkOr:
warn "Cannot increase open file limit", err = osErrorMsg(error)
proc setupLogging*(
logLevel: string, stdoutKind: StdoutLogKind, logFile: Option[OutFile]) =
# In the cfg file for nimbus, we create two formats: textlines and json.

View File

@ -556,5 +556,6 @@ programMain:
# and avoid using system resources (such as urandom) after that
rng = HmacDrbgContext.new()
setupFileLimits()
setupLogging(config.logLevel, config.logStdout, config.logFile)
waitFor runValidatorClient(config, rng)

View File

@ -48,6 +48,9 @@ Environment=METRICS_PORT=8008
Environment=REST_ENABLED=Yes
Environment=METRICS_ENABLED=Yes
# Apart from sockets and databases, a file descriptor is needed for every local validator
LimitNOFILE=16384
# Default group = nimbus
User=nimbus
WorkingDirectory=/var/lib/nimbus

View File

@ -39,6 +39,9 @@ Environment=METRICS_PORT=8108
# Interaction and monitoring
Environment=METRICS_ENABLED=Yes
# Apart from sockets and databases, a file descriptor is needed for every local validator
LimitNOFILE=16384
# Default group = nimbus
User=nimbus
WorkingDirectory=/var/lib/nimbus