mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 23:57:56 +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:
@@ -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(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user