Skip to content

Commit

Permalink
add health endpoint (#752)
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorvsadana authored Feb 2, 2024
1 parent 0807ed0 commit b499179
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions docker/rpc/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM python:3.9.13 as compiler
# install poetry
ENV POETRY_VERSION=1.7.1
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="$PATH:/root/.local/bin:/root/.foundry/bin"
RUN poetry config virtualenvs.create false
Expand Down
6 changes: 5 additions & 1 deletion src/eth_rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub mod rpc;
pub mod servers;

use eyre::Result;
use jsonrpsee::server::middleware::http::{InvalidPath, ProxyGetRequestLayer};
use jsonrpsee::server::{ServerBuilder, ServerHandle};
use jsonrpsee::RpcModule;
use thiserror::Error;
Expand All @@ -20,6 +21,8 @@ pub enum RpcError {
IoError(#[from] std::io::Error),
#[error(transparent)]
ParseError(#[from] AddrParseError),
#[error(transparent)]
JsonRpcError(#[from] InvalidPath),
}

/// # Errors
Expand All @@ -33,7 +36,8 @@ pub async fn run_server(

let cors = CorsLayer::new().allow_methods(Any).allow_origin(Any).allow_headers(Any);

let http_middleware = tower::ServiceBuilder::new().layer(cors);
let http_middleware =
tower::ServiceBuilder::new().layer(ProxyGetRequestLayer::new("/health", "net_health")?).layer(cors);

let server = ServerBuilder::default()
.max_connections(std::env::var("RPC_MAX_CONNECTIONS").unwrap_or("100".to_string()).parse().unwrap())
Expand Down

0 comments on commit b499179

Please sign in to comment.