fix(startup): wait for services to be ready #37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request fixes a race condition during startup that causes Ambxst to fail to initialize correctly on the first launch.
The issue is caused by the
daemon_priority.shscript, which is responsible for starting background services likelitellmandeasyeffects. This script is executed in the background by the maincli.shscript, which then immediately launches thequickshellUI.The UI's QML components attempt to connect to the background services as soon as they are initialized. However, because the
daemon_priority.shscript is running in parallel, the services are often not yet ready to accept connections. This results in connection failures and a broken user experience on the first start.On subsequent launches, the services from the first launch are already running, so the UI can connect successfully.
Fix
This PR addresses the race condition by modifying the
daemon_priority.shscript to wait for the services to become ready before exiting.wait_for_portfunction has been added to poll for a service on a given TCP port. This is used to wait forlitellmto be ready on port 4000.sleep 1command has been added after startingeasyeffectsto give it a moment to initialize, as it does not have a specific port to check.These changes ensure that the background services are fully initialized before the UI attempts to connect to them, resolving the startup issue.