Skip to content

Commit

Permalink
fix: health and readiness probe (#1038)
Browse files Browse the repository at this point in the history
it was not returning the actual status code
  • Loading branch information
renancloudwalk authored Jun 8, 2024
1 parent 1d14a53 commit bea1700
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 @@ -240,11 +240,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 bea1700

Please sign in to comment.