mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-26 20:54:08 +00:00
fix: return file logging initialization errors instead of panicking (#10478)
Signed-off-by: WenyXu <wenymedia@gmail.com>
This commit is contained in:
+2
-1
@@ -77,7 +77,8 @@ impl Command {
|
||||
&TracingOptions::default(),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
)
|
||||
.context(crate::error::InitLoggingSnafu)?;
|
||||
|
||||
let tool = self.cmd.build().await.context(error::BuildCliSnafu)?;
|
||||
let instance = Instance {
|
||||
|
||||
@@ -67,7 +67,8 @@ impl InstanceBuilder {
|
||||
&dn_opts.tracing,
|
||||
dn_opts.node_id.map(|x| x.to_string()),
|
||||
None,
|
||||
);
|
||||
)
|
||||
.context(crate::error::InitLoggingSnafu)?;
|
||||
|
||||
common_runtime::init_datanode_runtimes(&opts.runtime);
|
||||
|
||||
|
||||
@@ -23,6 +23,13 @@ use snafu::{Location, Snafu};
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to initialize logging"))]
|
||||
InitLogging {
|
||||
#[snafu(implicit)]
|
||||
location: Location,
|
||||
source: common_telemetry::logging::InitLoggingError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to install ring crypto provider: {}", msg))]
|
||||
InitTlsProvider {
|
||||
#[snafu(implicit)]
|
||||
@@ -337,6 +344,7 @@ pub type Result<T> = std::result::Result<T, Error>;
|
||||
impl ErrorExt for Error {
|
||||
fn status_code(&self) -> StatusCode {
|
||||
match self {
|
||||
Error::InitLogging { source, .. } => source.status_code(),
|
||||
Error::StartDatanode { source, .. } => source.status_code(),
|
||||
Error::StartFrontend { source, .. } => source.status_code(),
|
||||
Error::ShutdownDatanode { source, .. } => source.status_code(),
|
||||
|
||||
@@ -251,7 +251,8 @@ impl StartCommand {
|
||||
&opts.component.tracing,
|
||||
opts.component.node_id.map(|x| x.to_string()),
|
||||
None,
|
||||
);
|
||||
)
|
||||
.context(crate::error::InitLoggingSnafu)?;
|
||||
|
||||
common_runtime::init_global_runtimes(&opts.runtime);
|
||||
|
||||
|
||||
@@ -384,7 +384,8 @@ impl StartCommand {
|
||||
&opts.component.tracing,
|
||||
opts.component.node_id.clone(),
|
||||
Some(&opts.component.slow_query),
|
||||
);
|
||||
)
|
||||
.context(crate::error::InitLoggingSnafu)?;
|
||||
|
||||
common_runtime::init_global_runtimes(&opts.runtime);
|
||||
|
||||
|
||||
@@ -324,7 +324,8 @@ impl StartCommand {
|
||||
&opts.component.tracing,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
)
|
||||
.context(crate::error::InitLoggingSnafu)?;
|
||||
|
||||
common_runtime::init_global_runtimes(&opts.runtime);
|
||||
|
||||
|
||||
@@ -498,7 +498,8 @@ impl StartCommand {
|
||||
&opts.component.tracing,
|
||||
None,
|
||||
Some(&opts.component.slow_query),
|
||||
);
|
||||
)
|
||||
.context(crate::error::InitLoggingSnafu)?;
|
||||
|
||||
common_runtime::init_standalone_runtimes(&opts.runtime);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user