runme
runme copied to clipboard
internal/cmd/server: Ready message sent too early
Looks like there is a period between sending the "started listening" message and the server actually being ready. This is causing issues for vscode-runme, requiring them to poll for an active connection.
Hi @mxsdev,
It is possible that the delay between sending the "started listening" message and the server actually being ready is caused by the server taking some time to start up and initialize all the necessary components. This can be especially true if the server is running multiple services and interfaces.
To mitigate this issue, one possible approach is to add some additional logic to ensure that all necessary components are initialized and the server is fully operational before sending the "started listening" message. This can be achieved by adding some extra checks to the RunE function in internal/cmd/server.go, such as waiting for all services to be up and running, checking the server's health status, or verifying that all required dependencies are available.
Another approach is to use a health check endpoint that returns an HTTP 200 status code when the server is ready to receive traffic. This endpoint can be checked periodically by the vscode-runme tool to determine when the server is fully operational and ready to accept connections. The grpchealth package used in server.go file already provides a basic health check functionality that can be extended to include custom health checks.
Another approach is to use a health check endpoint that returns an HTTP 200 status code when the server is ready to receive traffic.
+1 and I remember @degrammer talking about a need for it. The extension should not rely on the logs produced by runme at all. This is going to cause you a lot of issues that will be hard to debug.
The grpchealth package used in server.go file already provides a basic health check functionality that can be extended to include custom health checks.
This is only for the Connect protocol but there is a guideline in the gRPC repo plus this implementation in various languages including Go.