mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-04 04:12:55 +00:00
refactor: add disable_dashboard option and disable dashboard in metasrv and datanode (#1343)
* refactor: add disable_dashboard option and disable dashboard in metasrv and datanode * refactor: skip disable_dashboard filed in toml file * refactor: simplify the http initialization
This commit is contained in:
@@ -168,6 +168,9 @@ impl TryFrom<StartCommand> for DatanodeOptions {
|
||||
opts.http_opts.timeout = Duration::from_secs(http_timeout)
|
||||
}
|
||||
|
||||
// Disable dashboard in datanode.
|
||||
opts.http_opts.disable_dashboard = true;
|
||||
|
||||
Ok(opts)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,8 @@ pub struct StartCommand {
|
||||
tls_key_path: Option<String>,
|
||||
#[clap(long)]
|
||||
user_provider: Option<String>,
|
||||
#[clap(long)]
|
||||
disable_dashboard: bool,
|
||||
}
|
||||
|
||||
impl StartCommand {
|
||||
@@ -149,18 +151,24 @@ impl TryFrom<StartCommand> for FrontendOptions {
|
||||
|
||||
let tls_option = TlsOption::new(cmd.tls_mode, cmd.tls_cert_path, cmd.tls_key_path);
|
||||
|
||||
let mut http_options = HttpOptions {
|
||||
disable_dashboard: cmd.disable_dashboard,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
if let Some(addr) = cmd.http_addr {
|
||||
opts.http_options = Some(HttpOptions {
|
||||
addr,
|
||||
..Default::default()
|
||||
});
|
||||
http_options.addr = addr;
|
||||
}
|
||||
|
||||
opts.http_options = Some(http_options);
|
||||
|
||||
if let Some(addr) = cmd.grpc_addr {
|
||||
opts.grpc_options = Some(GrpcOptions {
|
||||
addr,
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(addr) = cmd.mysql_addr {
|
||||
opts.mysql_options = Some(MysqlOptions {
|
||||
addr,
|
||||
@@ -227,6 +235,7 @@ mod tests {
|
||||
tls_cert_path: None,
|
||||
tls_key_path: None,
|
||||
user_provider: None,
|
||||
disable_dashboard: false,
|
||||
};
|
||||
|
||||
let opts: FrontendOptions = command.try_into().unwrap();
|
||||
@@ -289,6 +298,7 @@ mod tests {
|
||||
tls_cert_path: None,
|
||||
tls_key_path: None,
|
||||
user_provider: None,
|
||||
disable_dashboard: false,
|
||||
};
|
||||
|
||||
let fe_opts = FrontendOptions::try_from(command).unwrap();
|
||||
@@ -319,6 +329,7 @@ mod tests {
|
||||
tls_cert_path: None,
|
||||
tls_key_path: None,
|
||||
user_provider: Some("static_user_provider:cmd:test=test".to_string()),
|
||||
disable_dashboard: false,
|
||||
};
|
||||
|
||||
let plugins = load_frontend_plugins(&command.user_provider);
|
||||
|
||||
@@ -141,6 +141,9 @@ impl TryFrom<StartCommand> for MetaSrvOptions {
|
||||
opts.http_opts.timeout = Duration::from_secs(http_timeout);
|
||||
}
|
||||
|
||||
// Disable dashboard in metasrv.
|
||||
opts.http_opts.disable_dashboard = true;
|
||||
|
||||
Ok(opts)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,8 +118,12 @@ pub struct HttpServer {
|
||||
#[serde(default)]
|
||||
pub struct HttpOptions {
|
||||
pub addr: String,
|
||||
|
||||
#[serde(with = "humantime_serde")]
|
||||
pub timeout: Duration,
|
||||
|
||||
#[serde(skip)]
|
||||
pub disable_dashboard: bool,
|
||||
}
|
||||
|
||||
impl Default for HttpOptions {
|
||||
@@ -127,6 +131,7 @@ impl Default for HttpOptions {
|
||||
Self {
|
||||
addr: "127.0.0.1:4000".to_string(),
|
||||
timeout: Duration::from_secs(30),
|
||||
disable_dashboard: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -502,7 +507,10 @@ impl HttpServer {
|
||||
|
||||
#[cfg(feature = "dashboard")]
|
||||
{
|
||||
router = router.nest("/dashboard", dashboard::dashboard());
|
||||
if !self.options.disable_dashboard {
|
||||
info!("Enable dashboard service at '/dashboard'");
|
||||
router = router.nest("/dashboard", dashboard::dashboard());
|
||||
}
|
||||
}
|
||||
|
||||
router
|
||||
|
||||
Reference in New Issue
Block a user