@@ -34,6 +34,10 @@ const getLocalSubgraphConfig = (subgraphName) =>
3434 LOCAL_SUBGRAPH_CONFIG . find ( it => it . name === subgraphName ) ;
3535
3636export const startSubgraphs = async ( httpPort ) => {
37+ // Log pod ID for Kubernetes identification
38+ const podId = process . env . HOSTNAME || 'unknown' ;
39+ console . log ( `🚀 [${ podId } ] Starting subgraphs server...` ) ;
40+
3741 // Create a monolith express app for all subgraphs
3842 const app = express ( ) ;
3943 const httpServer = http . createServer ( app ) ;
@@ -66,6 +70,21 @@ export const startSubgraphs = async (httpPort) => {
6670 server : httpServer ,
6771 path,
6872 } ) ;
73+
74+ // Add WebSocket connection logging
75+ wsServer . on ( 'connection' , ( socket , request ) => {
76+ console . log ( `🔌 [${ podId } ] WebSocket connection established for [${ subgraphConfig . name } ] subgraph` ) ;
77+ console . log ( `🔌 [${ podId } ] Client IP: ${ request . socket . remoteAddress } ` ) ;
78+
79+ socket . on ( 'close' , ( ) => {
80+ console . log ( `🔌 [${ podId } ] WebSocket connection closed for [${ subgraphConfig . name } ] subgraph` ) ;
81+ } ) ;
82+
83+ socket . on ( 'error' , ( error ) => {
84+ console . log ( `❌ [${ podId } ] WebSocket error for [${ subgraphConfig . name } ] subgraph:` , error . message ) ;
85+ } ) ;
86+ } ) ;
87+
6988 const serverCleanup = useServer ( { schema } , wsServer ) ;
7089 wsPlugin = {
7190 async serverWillStart ( ) {
@@ -76,10 +95,10 @@ export const startSubgraphs = async (httpPort) => {
7695 } ;
7796 } ,
7897 } ;
79- console . log ( `Setting up WebSocket server for [${ subgraphConfig . name } ] subgraph at ws://localhost:${ serverPort } / ${ path } ` ) ;
98+ console . log ( `🚀 [ ${ podId } ] Setting up WebSocket server for [${ subgraphConfig . name } ] subgraph at ws://localhost:${ serverPort } ${ path } ` ) ;
8099 }
81100
82- console . log ( `Setting up HTTP server for [${ subgraphConfig . name } ] subgraph at http://localhost:${ serverPort } ${ path } ` ) ;
101+ console . log ( `🚀 [ ${ podId } ] Setting up HTTP server for [${ subgraphConfig . name } ] subgraph at http://localhost:${ serverPort } ${ path } ` ) ;
83102
84103 const server = new ApolloServer ( {
85104 schema,
@@ -110,4 +129,5 @@ export const startSubgraphs = async (httpPort) => {
110129
111130 // Start entire monolith at given port
112131 await new Promise ( ( resolve ) => httpServer . listen ( { port : serverPort } , resolve ) ) ;
132+ console . log ( `🚀 [${ podId } ] All subgraphs started and listening on port ${ serverPort } ` ) ;
113133} ;
0 commit comments