Skip to content

Commit

Permalink
fix: health and readiness probe
Browse files Browse the repository at this point in the history
it was not returning the actual status code
  • Loading branch information
renancloudwalk committed Jun 7, 2024
1 parent 12473d2 commit 75d2aac
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/eth/rpc/rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,20 @@ async fn stratus_startup(_: Params<'_>, _: Arc<RpcContext>, _: Extensions) -> an
async fn stratus_readiness(_: Params<'_>, context: Arc<RpcContext>, _: Extensions) -> anyhow::Result<JsonValue, RpcError> {
let should_serve = context.consensus.should_serve().await;
tracing::info!("stratus_readiness: {}", should_serve);
Ok(json!(should_serve))

if should_serve {
Ok(json!(true))
} else {
Err(RpcError::Response(rpc_internal_error("Service Not Ready".to_string())))
}
}

async fn stratus_liveness(_: Params<'_>, _: Arc<RpcContext>, _: Extensions) -> anyhow::Result<JsonValue, RpcError> {
Ok(json!(true))
if !GlobalState::is_shutdown() {
Ok(json!(true))
} else {
Err(RpcError::Response(rpc_internal_error("Service Unhealthy".to_string())))
}
}

// -----------------------------------------------------------------------------
Expand Down

0 comments on commit 75d2aac

Please sign in to comment.