Compiling source
ballerinax/HealthAudit:1.0.0
Running executable```
- AFAIS this `Running executable` doesn't guarantee that the service is started - is it a correct understanding?
- IIRC service url was printed earlier once it is started and it is not happening any more. This was useful as it gives us the exact service url in addition to indicating that the service is up.
#bal run - how to know whether the service is started?
1 messages · Page 1 of 1 (latest)
Running executableoutput indicates that the program execution has started. Therefore, it implies the service starting as well, unless there's any crash/error logs.- The log entries for the service start and stop were removed as an improvement. Because, such logs can be an inconvenience for the libraries/packages built on top of other libraries.
And if required, you can add logs inside the service init function with the required information, to indicate the service has initialized.
import ballerina/http;
import ballerina/log;
configurable int port = 9090;
service / on new http:Listener(port) {
function init() {
log:printInfo("Started HTTP/WS listener", host="0.0.0.0", port=port);
}
resource function get greeting() returns string {
return "Hello, World!";
}
}
Just to clarify though, initialization doesn't indicate that the listener has been started (and the service is ready to accept requests). If there is a main function, that will run after these logs are printed, but before the listener is started.
Issue discussing removing the logs - https://github.com/ballerina-platform/ballerina-standard-library/issues/2040
Unfortunately, I have to disagree as well. And it seems @timid harbor had the same concerns raised here - https://github.com/ballerina-platform/ballerina-standard-library/issues/2040#issuecomment-998421509 .. Ballerina is a language but in this instance it starts a service and developers who uses Ballerina to start services would like to know when exactly the service is ready to accept the requests. As @narrow nimbus mentioned, adding a log in the init() won't solve it either as there's no guarantee the listener is started. So, IMO we should not concerned about printing a one time single line log which is of utmost importance to know when exactly the service is ready.
Looping in @pastel bay also.