parent
c13907d1af
commit
49a3a7d6d1
|
@ -101,10 +101,19 @@ impl Application for ZebradApp {
|
||||||
metrics::MetricsEndpoint, tokio::TokioComponent, tracing::TracingEndpoint,
|
metrics::MetricsEndpoint, tokio::TokioComponent, tracing::TracingEndpoint,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// `None` outputs zebrad usage information and exits
|
||||||
|
let command_is_server = match &command.command {
|
||||||
|
None => false,
|
||||||
|
Some(c) => c.is_server(),
|
||||||
|
};
|
||||||
|
|
||||||
let mut components = self.framework_components(command)?;
|
let mut components = self.framework_components(command)?;
|
||||||
components.push(Box::new(TokioComponent::new()?));
|
components.push(Box::new(TokioComponent::new()?));
|
||||||
components.push(Box::new(TracingEndpoint::new()?));
|
// Launch network endpoints for long-running commands
|
||||||
components.push(Box::new(MetricsEndpoint::new()?));
|
if command_is_server {
|
||||||
|
components.push(Box::new(TracingEndpoint::new()?));
|
||||||
|
components.push(Box::new(MetricsEndpoint::new()?));
|
||||||
|
}
|
||||||
|
|
||||||
self.state.components.register(components)
|
self.state.components.register(components)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,14 @@ mod seed;
|
||||||
mod start;
|
mod start;
|
||||||
mod version;
|
mod version;
|
||||||
|
|
||||||
|
use self::ZebradCmd::*;
|
||||||
use self::{
|
use self::{
|
||||||
connect::ConnectCmd, generate::GenerateCmd, revhex::RevhexCmd, seed::SeedCmd, start::StartCmd,
|
connect::ConnectCmd, generate::GenerateCmd, revhex::RevhexCmd, seed::SeedCmd, start::StartCmd,
|
||||||
version::VersionCmd,
|
version::VersionCmd,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::config::ZebradConfig;
|
use crate::config::ZebradConfig;
|
||||||
|
|
||||||
use abscissa_core::{
|
use abscissa_core::{
|
||||||
config::Override, Command, Configurable, FrameworkError, Help, Options, Runnable,
|
config::Override, Command, Configurable, FrameworkError, Help, Options, Runnable,
|
||||||
};
|
};
|
||||||
|
@ -61,13 +64,27 @@ impl ZebradCmd {
|
||||||
/// If the command is `None`, then abscissa writes zebrad usage information
|
/// If the command is `None`, then abscissa writes zebrad usage information
|
||||||
/// to stdout.
|
/// to stdout.
|
||||||
pub(crate) fn uses_stdout(&self) -> bool {
|
pub(crate) fn uses_stdout(&self) -> bool {
|
||||||
use ZebradCmd::*;
|
|
||||||
match self {
|
match self {
|
||||||
// List all the commands, so new commands have to make a choice here
|
// List all the commands, so new commands have to make a choice here
|
||||||
Generate(_) | Help(_) | Revhex(_) | Version(_) => true,
|
Generate(_) | Help(_) | Revhex(_) | Version(_) => true,
|
||||||
Connect(_) | Seed(_) | Start(_) => false,
|
Connect(_) | Seed(_) | Start(_) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if this command is a server command.
|
||||||
|
///
|
||||||
|
/// For example, `Start` acts as a Zcash node.
|
||||||
|
///
|
||||||
|
/// Usage note: `abscissa_core::EntryPoint` stores an `Option<ZerbradCmd>`.
|
||||||
|
/// If the command is `None`, then abscissa prints zebrad's usage
|
||||||
|
/// information, then exits.
|
||||||
|
pub(crate) fn is_server(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
// List all the commands, so new commands have to make a choice here
|
||||||
|
Connect(_) | Seed(_) | Start(_) => true,
|
||||||
|
Generate(_) | Help(_) | Revhex(_) | Version(_) => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This trait allows you to define how application configuration is loaded.
|
/// This trait allows you to define how application configuration is loaded.
|
||||||
|
|
Loading…
Reference in New Issue