Skip to content

Commit

Permalink
fix: drive status report
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov committed Oct 17, 2024
1 parent af02a83 commit 09d1c35
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
6 changes: 5 additions & 1 deletion packages/dashmate/src/commands/status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ export default class StatusCommand extends ConfigBaseCommand {

plain['Platform Enabled'] = platform.enabled || 'n/a';

const platformStatus = platform.tenderdash.serviceStatus !== ServiceStatusEnum.up
? platform.tenderdash.serviceStatus
: platform.drive.serviceStatus;

if (platform.enabled) {
plain['Platform Status'] = colors.status(platform.tenderdash.serviceStatus)(platform.tenderdash.serviceStatus) || 'n/a';
plain['Platform Status'] = colors.status(platformStatus)(platformStatus) || 'n/a';

if (platform.tenderdash.serviceStatus === ServiceStatusEnum.up) {
plain['Platform Version'] = platform.tenderdash.version || 'n/a';
Expand Down
3 changes: 2 additions & 1 deletion packages/dashmate/src/status/scopes/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ export default function getOverviewScopeFactory(
}

if (config.get('platform.enable')) {
const { tenderdash } = await getPlatformScope(config);
const { drive, tenderdash } = await getPlatformScope(config);

platform.drive = drive;
platform.tenderdash = tenderdash;
}

Expand Down
10 changes: 6 additions & 4 deletions packages/dashmate/src/status/scopes/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ export default function getPlatformScopeFactory(
} catch (e) {
if (e instanceof ContainerIsNotPresentError) {
info.dockerStatus = DockerStatusEnum.not_started;
} else {
throw e;
}

throw e;
}

info.serviceStatus = determineStatus.platform(info.dockerStatus, isCoreSynced, mnRRSoftFork);
Expand All @@ -186,11 +186,13 @@ export default function getPlatformScopeFactory(
&& e.dockerComposeExecutionResult
&& e.dockerComposeExecutionResult.exitCode !== 0) {
info.serviceStatus = ServiceStatusEnum.error;
} else {
throw e;
}

throw e;
}
}

return info;
};

/**
Expand Down
24 changes: 9 additions & 15 deletions packages/rs-drive-abci/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use dpp::version::PlatformVersion;
use drive_abci::config::{FromEnv, PlatformConfig};
use drive_abci::core::wait_for_core_to_sync::v0::wait_for_core_to_sync_v0;
use drive_abci::logging::{LogBuilder, LogConfig, LogDestination, Loggers};
use drive_abci::metrics::{Prometheus, DEFAULT_PROMETHEUS_PORT};
use drive_abci::metrics::Prometheus;
use drive_abci::platform_types::platform::Platform;
use drive_abci::rpc::core::DefaultCoreRPC;
use drive_abci::{logging, server};
Expand Down Expand Up @@ -103,7 +103,6 @@ impl Cli {
) -> Result<(), String> {
match self.command {
Commands::Start => {
// Start runtime in the main thread
tracing::info!(
version = env!("CARGO_PKG_VERSION"),
features = list_enabled_features().join(","),
Expand Down Expand Up @@ -216,6 +215,7 @@ fn main() -> Result<(), ExitCode> {

install_panic_hook(cancel.clone());

// Start runtime in the main thread
let runtime_guard = runtime.enter();

runtime.spawn(handle_signals(cancel.clone(), loggers));
Expand All @@ -226,7 +226,7 @@ fn main() -> Result<(), ExitCode> {
Ok(())
}
Err(e) => {
tracing::error!(error = e, "drive-abci failed");
tracing::error!(error = e, "drive-abci failed: {e}");
Err(ExitCode::FAILURE)
}
};
Expand Down Expand Up @@ -310,12 +310,13 @@ fn list_enabled_features() -> Vec<&'static str> {
/// Check status of ABCI server.
async fn check_status(config: &PlatformConfig) -> Result<(), String> {
// Convert the gRPC bind address string to a Uri
let uri = Uri::from_str(&config.grpc_bind_address).map_err(|e| e.to_string())?;
let uri = Uri::from_str(&format!("http://{}", config.grpc_bind_address))
.map_err(|e| format!("invalid url: {e}"))?;

// Connect to the gRPC server
let mut client = PlatformClient::connect(uri)
let mut client = PlatformClient::connect(uri.clone())
.await
.map_err(|e| e.to_string())?;
.map_err(|e| format!("can't connect to grpc server {uri}: {e}"))?;

// Make a request to the server
let request = dapi_grpc::platform::v0::GetStatusRequest {
Expand All @@ -327,7 +328,7 @@ async fn check_status(config: &PlatformConfig) -> Result<(), String> {
.get_status(request)
.await
.map(|_| ())
.map_err(|e| e.to_string())
.map_err(|e| format!("can't request status: {e}"))
}

/// Verify GroveDB integrity.
Expand Down Expand Up @@ -415,7 +416,7 @@ fn configure_logging(cli: &Cli, config: &PlatformConfig) -> Result<Loggers, logg
if configs.is_empty() || cli.verbose > 0 {
let cli_config = LogConfig {
destination: LogDestination::StdOut,
level: cli.verbose.try_into().unwrap(),
level: cli.verbose.try_into()?,
color: cli.color,
..Default::default()
};
Expand Down Expand Up @@ -445,13 +446,11 @@ mod test {
use ::drive::{drive::Drive, query::Element};
use dpp::block::epoch::Epoch;
use drive::drive::credit_pools::epochs::epoch_key_constants;
use std::str::FromStr;
use std::{
fs,
path::{Path, PathBuf},
};

use dapi_grpc::tonic::transport::Uri;
use dpp::version::PlatformVersion;
use drive::drive::credit_pools::epochs::paths::EpochProposers;
use drive_abci::logging::LogLevel;
Expand Down Expand Up @@ -542,9 +541,4 @@ mod test {

println!("db path: {:?}", &db_path);
}

#[test]
fn test_uri_conversion_from_server_bind_address() {
Uri::from_str("0.0.0.0:1324").expect("should parse");
}
}

0 comments on commit 09d1c35

Please sign in to comment.