mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-05 12:57:42 +00:00
refactor: reuse embedded lifecycle publication boundaries (#3642)
This commit is contained in:
+3
-13
@@ -48,7 +48,7 @@
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::server::{ShutdownHandle, start_http_server};
|
||||
use crate::startup_iam::publish_ready_for_iam_bootstrap;
|
||||
use crate::startup_lifecycle::{log_embedded_server_ready, publish_embedded_startup_ready};
|
||||
use crate::startup_server::init_embedded_startup_listen_context;
|
||||
use crate::startup_services::init_embedded_startup_runtime_services;
|
||||
use crate::startup_shutdown::run_embedded_shutdown_cleanup;
|
||||
@@ -335,15 +335,13 @@ impl RustFSServerBuilder {
|
||||
ServerError::Init(e.to_string())
|
||||
})?;
|
||||
|
||||
publish_ready_for_iam_bootstrap(service_runtime.iam_bootstrap, listen_context.readiness.as_ref(), None)
|
||||
publish_embedded_startup_ready(service_runtime.iam_bootstrap, listen_context.readiness.as_ref())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
shutdown_embedded_server();
|
||||
ServerError::Init(format!("runtime readiness: {e}"))
|
||||
})?;
|
||||
|
||||
rustfs_common::set_global_init_time_now().await;
|
||||
|
||||
let server = RustFSServer {
|
||||
address: bound_addr,
|
||||
access_key: self.access_key.clone(),
|
||||
@@ -354,15 +352,7 @@ impl RustFSServerBuilder {
|
||||
temp_dir: temp_dir_guard.map(|g| g.keep()),
|
||||
};
|
||||
|
||||
info!(
|
||||
target: "rustfs::embedded",
|
||||
component = LOG_COMPONENT_EMBEDDED,
|
||||
subsystem = LOG_SUBSYSTEM_EMBEDDED,
|
||||
event = "embedded_server_state",
|
||||
state = "ready",
|
||||
"RustFS embedded server ready at http://{}",
|
||||
server.endpoint_address()
|
||||
);
|
||||
log_embedded_server_ready(server.endpoint_address());
|
||||
|
||||
Ok(server)
|
||||
}
|
||||
|
||||
@@ -14,21 +14,24 @@
|
||||
|
||||
use crate::{
|
||||
server::{ServiceStateManager, ShutdownHandle, wait_for_shutdown},
|
||||
startup_iam::publish_ready_for_iam_bootstrap,
|
||||
startup_iam::{IamBootstrapDisposition, publish_ready_for_iam_bootstrap},
|
||||
startup_services::StartupServiceRuntime,
|
||||
startup_shutdown::run_startup_shutdown_sequence,
|
||||
storage_compat::ECStore,
|
||||
};
|
||||
use rustfs_common::GlobalReadiness;
|
||||
use rustfs_scanner::init_data_scanner;
|
||||
use std::{io::Result, sync::Arc};
|
||||
use std::{io::Result, net::SocketAddr, sync::Arc};
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use tracing::info;
|
||||
|
||||
const LOG_COMPONENT_MAIN: &str = "main";
|
||||
const LOG_COMPONENT_EMBEDDED: &str = "embedded";
|
||||
const LOG_SUBSYSTEM_STARTUP: &str = "startup";
|
||||
const LOG_SUBSYSTEM_EMBEDDED: &str = "embedded";
|
||||
const EVENT_SERVER_READY: &str = "server_ready";
|
||||
const EVENT_SERVER_SHUTDOWN_STATE: &str = "server_shutdown_state";
|
||||
const EVENT_EMBEDDED_SERVER_STATE: &str = "embedded_server_state";
|
||||
|
||||
pub struct StartupRuntimeLifecycle {
|
||||
pub server_address: String,
|
||||
@@ -98,3 +101,21 @@ pub async fn run_startup_runtime_lifecycle(lifecycle: StartupRuntimeLifecycle) -
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn publish_embedded_startup_ready(iam_bootstrap: IamBootstrapDisposition, readiness: &GlobalReadiness) -> Result<()> {
|
||||
publish_ready_for_iam_bootstrap(iam_bootstrap, readiness, None).await?;
|
||||
rustfs_common::set_global_init_time_now().await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn log_embedded_server_ready(endpoint_address: SocketAddr) {
|
||||
info!(
|
||||
target: "rustfs::embedded",
|
||||
component = LOG_COMPONENT_EMBEDDED,
|
||||
subsystem = LOG_SUBSYSTEM_EMBEDDED,
|
||||
event = EVENT_EMBEDDED_SERVER_STATE,
|
||||
state = "ready",
|
||||
"RustFS embedded server ready at http://{}",
|
||||
endpoint_address
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user