diff --git a/src/control_server_entrypoint.rs b/src/control_server_entrypoint.rs index cc1d213478339044435115a319688bc90d57284c..2c2746f8bfc63ff740977d7f69272f08fad65a39 100644 --- a/src/control_server_entrypoint.rs +++ b/src/control_server_entrypoint.rs @@ -19,6 +19,7 @@ use crate::util::error::Result; use clap::Parser; use config::Config; use std::env; +use std::fs; use std::sync::{Arc, RwLock}; use tokio::{ select, @@ -48,6 +49,9 @@ pub struct App { help = "path of configuration file, 'config/server.toml' relative to working directory be used in default" )] config: Option, + #[arg(short, long)] + #[arg(help = "whether to remove config file when server started")] + remove_config: Option, } lazy_static! { @@ -73,9 +77,12 @@ lazy_static! { let app = App::parse(); let path = app.config.unwrap_or(format!("{}/{}", env::current_dir().expect("current dir not found").display(), "config/server.toml")); - let server_config = util::config::ServerConfig::new(path); + let server_config = util::config::ServerConfig::new(path.clone()); //TODO: Enable watch configure file will lead to 100 percent cpu consumption, fix it later //server_config.watch(CANCEL_TOKEN.clone()).expect("failed to watch configure file"); + if app.remove_config.unwrap_or(false) { + fs::remove_file(path).expect("failed to remove config file"); + } server_config.config }; } diff --git a/src/data_server_entrypoint.rs b/src/data_server_entrypoint.rs index d2f656ece629bc189b059f70aa8cac3a13d19f5d..1fa9ab542e10eba57bb3252ea3d9c72012339182 100644 --- a/src/data_server_entrypoint.rs +++ b/src/data_server_entrypoint.rs @@ -19,6 +19,7 @@ use crate::util::error::Result; use clap::Parser; use config::Config; use std::env; +use std::fs; use std::sync::{Arc, RwLock}; use tokio::{ select, @@ -50,6 +51,9 @@ pub struct App { help = "path of configuration file, 'config/server.toml' relative to working directory be used in default" )] config: Option, + #[arg(short, long)] + #[arg(help = "whether to remove config file when server started")] + remove_config: Option, } lazy_static! { @@ -75,9 +79,12 @@ lazy_static! { let app = App::parse(); let path = app.config.unwrap_or(format!("{}/{}", env::current_dir().expect("current dir not found").display(), "config/server.toml")); - let server_config = util::config::ServerConfig::new(path); + let server_config = util::config::ServerConfig::new(path.clone()); //TODO: Enable watch configure file will lead to 100 percent cpu consumption, fix it later //server_config.watch(CANCEL_TOKEN.clone()).expect("failed to watch configure file"); + if app.remove_config.unwrap_or(false) { + fs::remove_file(path).expect("failed to remove config file"); + } server_config.config }; } diff --git a/src/infra/sign_plugin/x509.rs b/src/infra/sign_plugin/x509.rs index 5a01fce9690edc6dfc5cd9a99243112266fc6a26..f8ab89b4702b5615e21fc06d1e4eca1988f8e5ba 100644 --- a/src/infra/sign_plugin/x509.rs +++ b/src/infra/sign_plugin/x509.rs @@ -278,7 +278,7 @@ impl X509Plugin { #[allow(deprecated)] fn generate_x509ica_keys( &self, - infra_config: &HashMap, + _infra_config: &HashMap, ) -> Result { let parameter = attributes_validate::(&self.attributes)?; //load the ca certificate and private key @@ -381,7 +381,7 @@ impl X509Plugin { #[allow(deprecated)] fn generate_x509ee_keys( &self, - infra_config: &HashMap, + _infra_config: &HashMap, ) -> Result { let parameter = attributes_validate::(&self.attributes)?; //load the ca certificate and private key