@@ -122,10 +122,10 @@ resolve_platform() {
122122# GitHub API or thunderid.dev calls of our own and no version pinned in this repo, downloads it for
123123# the current platform, and runs setup.sh non-interactively (admin credentials passed through via
124124# THUNDERID_ADMIN_* env vars). It always finishes by trying to attach its interactive REPL, which
125- # needs a real TTY and fails in a script; that is expected, so its exit code is ignored below. By
126- # the time it fails, the release is already downloaded and fully set up on disk , so we start it
127- # ourselves with `start.sh` rather than relying on npx thunderid's own ( REPL-attached) background
128- # process, which does not outlive the npx invocation . A scratch HOME is used for that one
125+ # needs a real TTY and fails in a script; that is expected, so its exit code is ignored below. npx
126+ # thunderid already health-checked the server it started before that point , so we only start it
127+ # ourselves with `start.sh` if it isn't actually reachable (e.g. the REPL failure tore it down)
128+ # instead of racing a second instance onto the same port . A scratch HOME is used for that one
129129# invocation so it can't see, or reuse, a version already active from a developer's own separate
130130# `npx thunderid` use on this machine, guaranteeing a fresh "no active version" state and therefore
131131# the true latest release every run.
@@ -183,7 +183,7 @@ download_and_start_server() {
183183 fi
184184
185185 echo " Starting ThunderID server..."
186- (cd " $DIST_HOME " && ./start.sh) &
186+ curl -sk " https://localhost: ${SERVER_PORT} /health/liveness " > /dev/null 2>&1 || (cd " $DIST_HOME " && ./start.sh & )
187187 wait_for_url " https://localhost:${SERVER_PORT} /health/liveness" " ThunderID server"
188188}
189189
0 commit comments