Managing server from UNO?

When one wants to use UNO API in the script, they should start LibreOffice with --headless option. But because of the 4 years old bug one couldn’t once start a server, and don’t care about it anymore — the server always needs to be started just before the script, and killed just after the script worked out.

Is there a way to either use UNO without the server, either somehow start the server from the API itself, so that the script would be able to see when it’s ready to accept connections?

ATM I am using a workaround where I am starting a server, and then wait for some time because otherwise the code would be executed before the server ready to accept connections.