mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 23:08:03 +00:00
client/cli/src/config: Warn on low file descriptor limit (#6956)
* client/cli/src/config: Warn on low file descriptor limit Substrate sets the soft file descriptor limit to the hard limit at startup. In the case of the latter being low already (< 10_000) a Substrate node under high demand might run into issues e.g. when opening up new TCP connections or persisting data to the database. With this commit a warn message is printed to stderr. * client/cli/Cargo.toml: Update to fdlimit 0.2.0
This commit is contained in:
Generated
+2
-2
@@ -1486,9 +1486,9 @@ checksum = "36a9cb09840f81cd211e435d00a4e487edd263dc3c8ff815c32dd76ad668ebed"
|
||||
|
||||
[[package]]
|
||||
name = "fdlimit"
|
||||
version = "0.1.4"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0da54a593b34c71b889ee45f5b5bb900c74148c5f7f8c6a9479ee7899f69603c"
|
||||
checksum = "47bc6e222b8349b2bd0acb85a1d16d22852376b3ceed2a7f09c2692c3d8a78d0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
@@ -22,7 +22,7 @@ ansi_term = "0.12.1"
|
||||
lazy_static = "1.4.0"
|
||||
tokio = { version = "0.2.21", features = [ "signal", "rt-core", "rt-threaded", "blocking" ] }
|
||||
futures = "0.3.4"
|
||||
fdlimit = "0.1.4"
|
||||
fdlimit = "0.2.0"
|
||||
libp2p = "0.24.0"
|
||||
parity-scale-codec = "1.3.0"
|
||||
hex = "0.4.2"
|
||||
|
||||
@@ -24,6 +24,7 @@ use crate::{
|
||||
init_logger, DatabaseParams, ImportParams, KeystoreParams, NetworkParams, NodeKeyParams,
|
||||
OffchainWorkerParams, PruningParams, SharedParams, SubstrateCli,
|
||||
};
|
||||
use log::warn;
|
||||
use names::{Generator, Name};
|
||||
use sc_client_api::execution_extensions::ExecutionStrategies;
|
||||
use sc_service::config::{
|
||||
@@ -38,9 +39,12 @@ use std::path::PathBuf;
|
||||
/// The maximum number of characters for a node name.
|
||||
pub(crate) const NODE_NAME_MAX_LENGTH: usize = 64;
|
||||
|
||||
/// default sub directory to store network config
|
||||
/// Default sub directory to store network config.
|
||||
pub(crate) const DEFAULT_NETWORK_CONFIG_PATH: &'static str = "network";
|
||||
|
||||
/// The recommended open file descriptor limit to be configured for the process.
|
||||
const RECOMMENDED_OPEN_FILE_DESCRIPTOR_LIMIT: u64 = 10_000;
|
||||
|
||||
/// Default configuration values used by Substrate
|
||||
///
|
||||
/// These values will be used by [`CliConfiguritation`] to set
|
||||
@@ -531,17 +535,26 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
||||
///
|
||||
/// This method:
|
||||
///
|
||||
/// 1. Set the panic handler
|
||||
/// 2. Raise the FD limit
|
||||
/// 3. Initialize the logger
|
||||
/// 1. Sets the panic handler
|
||||
/// 2. Initializes the logger
|
||||
/// 3. Raises the FD limit
|
||||
fn init<C: SubstrateCli>(&self) -> Result<()> {
|
||||
let logger_pattern = self.log_filters()?;
|
||||
|
||||
sp_panic_handler::set(&C::support_url(), &C::impl_version());
|
||||
|
||||
fdlimit::raise_fd_limit();
|
||||
init_logger(&logger_pattern);
|
||||
|
||||
if let Some(new_limit) = fdlimit::raise_fd_limit() {
|
||||
if new_limit < RECOMMENDED_OPEN_FILE_DESCRIPTOR_LIMIT {
|
||||
warn!(
|
||||
"Low open file descriptor limit configured for the process. \
|
||||
Current value: {:?}, recommended value: {:?}.",
|
||||
new_limit, RECOMMENDED_OPEN_FILE_DESCRIPTOR_LIMIT,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ tokio = "0.1.22"
|
||||
futures01 = { package = "futures", version = "0.1.29" }
|
||||
log = "0.4.8"
|
||||
env_logger = "0.7.0"
|
||||
fdlimit = "0.1.4"
|
||||
fdlimit = "0.2.0"
|
||||
parking_lot = "0.10.0"
|
||||
sc-light = { version = "2.0.0-rc6", path = "../../light" }
|
||||
sp-blockchain = { version = "2.0.0-rc6", path = "../../../primitives/blockchain" }
|
||||
|
||||
Reference in New Issue
Block a user