forked from Deuxfleurs/garage
Make admin server optional
This commit is contained in:
parent
a19341b188
commit
9b2b531f4d
2 changed files with 15 additions and 8 deletions
|
@ -68,10 +68,14 @@ pub async fn run_server(config_file: PathBuf) -> Result<(), Error> {
|
||||||
wait_from(watch_cancel.clone()),
|
wait_from(watch_cancel.clone()),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
let admin_server = if let Some(admin_bind_addr) = config.admin.api_bind_addr {
|
||||||
info!("Configure and run admin web server...");
|
info!("Configure and run admin web server...");
|
||||||
let admin_server = tokio::spawn(
|
Some(tokio::spawn(
|
||||||
admin_server_init.run(config.admin.api_bind_addr, wait_from(watch_cancel.clone())),
|
admin_server_init.run(admin_bind_addr, wait_from(watch_cancel.clone())),
|
||||||
);
|
))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
// Stuff runs
|
// Stuff runs
|
||||||
|
|
||||||
|
@ -82,9 +86,11 @@ pub async fn run_server(config_file: PathBuf) -> Result<(), Error> {
|
||||||
if let Err(e) = web_server.await? {
|
if let Err(e) = web_server.await? {
|
||||||
warn!("Web server exited with error: {}", e);
|
warn!("Web server exited with error: {}", e);
|
||||||
}
|
}
|
||||||
if let Err(e) = admin_server.await? {
|
if let Some(a) = admin_server {
|
||||||
|
if let Err(e) = a.await? {
|
||||||
warn!("Admin web server exited with error: {}", e);
|
warn!("Admin web server exited with error: {}", e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove RPC handlers for system to break reference cycles
|
// Remove RPC handlers for system to break reference cycles
|
||||||
garage.system.netapp.drop_all_handlers();
|
garage.system.netapp.drop_all_handlers();
|
||||||
|
|
|
@ -75,6 +75,7 @@ pub struct Config {
|
||||||
pub s3_web: WebConfig,
|
pub s3_web: WebConfig,
|
||||||
|
|
||||||
/// Configuration for the admin API endpoint
|
/// Configuration for the admin API endpoint
|
||||||
|
#[serde(default = "Default::default")]
|
||||||
pub admin: AdminConfig,
|
pub admin: AdminConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,10 +101,10 @@ pub struct WebConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configuration for the admin and monitoring HTTP API
|
/// Configuration for the admin and monitoring HTTP API
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone, Default)]
|
||||||
pub struct AdminConfig {
|
pub struct AdminConfig {
|
||||||
/// Address and port to bind for admin API serving
|
/// Address and port to bind for admin API serving
|
||||||
pub api_bind_addr: SocketAddr,
|
pub api_bind_addr: Option<SocketAddr>,
|
||||||
/// OTLP server to where to export traces
|
/// OTLP server to where to export traces
|
||||||
pub trace_sink: Option<String>,
|
pub trace_sink: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue