Skip to content

Commit e85fe07

Browse files
author
cyberfly
committed
check
1 parent 3c235b2 commit e85fe07

1 file changed

Lines changed: 53 additions & 20 deletions

File tree

src/main.rs

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -671,24 +671,40 @@ async fn main() -> Result<()> {
671671
// Create outbound sync channel so other components (GraphQL) can send SyncMessage to network
672672
let (sync_out_tx, sync_out_rx) = tokio::sync::mpsc::unbounded_channel::<crate::sync::SyncMessage>();
673673

674-
let graphql_server = graphql::create_server(
675-
storage.clone(),
676-
ipfs,
677-
Some(sync_manager),
678-
Some(endpoint_for_graphql), // Pass endpoint instead of wrapped network
679-
Some(discovered_peers_map), // Pass discovered peers map
680-
None, // IrohNetwork not needed - GraphQL uses Endpoint directly
681-
Some(peer_registry.clone()), // Pass PeerRegistry for mesh summary
682-
Some(network_resilience.clone()), // Pass NetworkResilience for circuit breaker, reputation, bandwidth
683-
relay_url_with_public_ip, // Pass relay URL with public IP
684-
mqtt_tx,
685-
mqtt_to_gossip_tx,
686-
mqtt_store,
687-
Some(message_broadcast_tx.clone()),
688-
Some(sync_out_tx.clone()),
689-
Some(inference_scheduler),
690-
)
691-
.await?;
674+
tracing::info!("🔧 Creating GraphQL server...");
675+
let graphql_server = match tokio::time::timeout(
676+
tokio::time::Duration::from_secs(30),
677+
graphql::create_server(
678+
storage.clone(),
679+
ipfs,
680+
Some(sync_manager),
681+
Some(endpoint_for_graphql), // Pass endpoint instead of wrapped network
682+
Some(discovered_peers_map), // Pass discovered peers map
683+
None, // IrohNetwork not needed - GraphQL uses Endpoint directly
684+
Some(peer_registry.clone()), // Pass PeerRegistry for mesh summary
685+
Some(network_resilience.clone()), // Pass NetworkResilience for circuit breaker, reputation, bandwidth
686+
relay_url_with_public_ip, // Pass relay URL with public IP
687+
mqtt_tx,
688+
mqtt_to_gossip_tx,
689+
mqtt_store,
690+
Some(message_broadcast_tx.clone()),
691+
Some(sync_out_tx.clone()),
692+
Some(inference_scheduler),
693+
)
694+
).await {
695+
Ok(Ok(server)) => {
696+
tracing::info!("✅ GraphQL server created successfully");
697+
server
698+
}
699+
Ok(Err(e)) => {
700+
tracing::error!("❌ GraphQL server creation failed: {}", e);
701+
return Err(e);
702+
}
703+
Err(_) => {
704+
tracing::error!("❌ GraphQL server creation timed out after 30s");
705+
return Err(anyhow::anyhow!("GraphQL server creation timeout - possible resource exhaustion or deadlock"));
706+
}
707+
};
692708
tracing::info!("GraphQL server initialized with WebSocket subscription support");
693709

694710
// Start network event loop on a dedicated Tokio runtime thread.
@@ -745,8 +761,25 @@ async fn main() -> Result<()> {
745761
});
746762

747763
// Start GraphQL API server
748-
let listener =
749-
tokio::net::TcpListener::bind(format!("{}:{}", config.api_host, config.api_port)).await?;
764+
tracing::info!("🔌 Binding API server to {}:{}", config.api_host, config.api_port);
765+
let listener = match tokio::net::TcpListener::bind(
766+
format!("{}:{}", config.api_host, config.api_port)
767+
).await {
768+
Ok(l) => {
769+
tracing::info!("✅ API server bound successfully");
770+
l
771+
}
772+
Err(e) => {
773+
tracing::error!(
774+
"❌ Failed to bind API server to {}:{} - {}",
775+
config.api_host,
776+
config.api_port,
777+
e
778+
);
779+
tracing::error!(" Port may already be in use or insufficient permissions");
780+
return Err(e.into());
781+
}
782+
};
750783

751784
// Get public IP for informational logging
752785
let api_public_ip = match kadena::get_public_ip().await {

0 commit comments

Comments
 (0)