Skip to content

Commit

Permalink
Add panic handler and logs (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasPennie authored and jjsloboda committed Nov 25, 2024
1 parent 0f69641 commit 25d34e8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions yellowstone-grpc-geyser/src/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,18 @@ impl GrpcService {
let shutdown = Arc::new(Notify::new());
let shutdown_grpc = Arc::clone(&shutdown);
tokio::spawn(async move {
// Add low-overhead panic hook without affecting any hooks added by Solana.
let old_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |panic_info| {
error!("gRPC server task panicked: {:?}", panic_info);
old_hook(panic_info); // Chain to the previous hook
}));

// gRPC Health check service
let (mut health_reporter, health_service) = health_reporter();
health_reporter.set_serving::<GeyserServer<Self>>().await;

server_builder
let result = server_builder
.http2_keepalive_interval(Some(Duration::from_secs(5)))
.layer(interceptor(move |request: Request<()>| {
if let Some(x_token) = &config.x_token {
Expand All @@ -437,7 +444,12 @@ impl GrpcService {
.add_service(health_service)
.add_service(service)
.serve_with_incoming_shutdown(incoming, shutdown_grpc.notified())
.await
.await;

match result {
Ok(_) => info!("gRPC server task finished"),
Err(e) => error!("gRPC server task failed: {e}"),
}
});

Ok((snapshot_tx, messages_tx, shutdown))
Expand Down

0 comments on commit 25d34e8

Please sign in to comment.