Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Normalize the /api/health wait and extract it into one script (#8060)
Daniel Han95d9f23a6481
diff --git a/.github/scripts/wait-for-health.sh b/.github/scripts/wait-for-health.shnew file mode 100755index 00000000000..270a36d9737--- /dev/null+++ b/.github/scripts/wait-for-health.sh@@ -0,0 +1,80 @@+#!/usr/bin/env bash+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.+#+# Poll a booted Studio's /api/health until it reports healthy, and on timeout+# print the tail of that server's log before failing.+#+# Usage:+# wait-for-health.sh --port 18888 [--log logs/studio.log] [--tmp /tmp/health.json]+#+# Fourteen steps across eight workflows ran this same poll, in two dialects that+# disagreed about what a failure looks like. This is the union of the two, taking+# the better half of each:+#+# * Retry on ANY not-yet-healthy answer, not just on a refused connection. The+# "exit-0" dialect ran `jq -e` as a bare command under `bash -e`, so a server+# that answered the very first poll with `status != "healthy"` failed the step+# on the spot instead of giving the model loader the remaining seconds. The+# other eleven copies already retried; now all fourteen do.+# * Tail the log when the deadline passes. Eleven copies ended on a bare+# `jq -e '.status == "healthy"'`, whose entire output on failure is a non-zero+# exit code -- no message, and nothing about why the server never came up. The+# log tail is the only place that says.+#+# Parameters, and why each one is a parameter:+#+# * --port differs per call site; several workflows run two or three servers in+# one job on different ports.+# * --log is whichever log the matching boot-studio-api-only.sh call was told+# to write. Five distinct names are in use, and tailing the wrong one+# on failure is worse than tailing none.+# * --tmp is where the last poll's response body is left for later steps and+# for a human reading the runner. Five distinct names are in use so+# that a later phase in the same job does not overwrite the evidence+# an earlier phase left behind.+#+# The deadline is fixed at 180s because all fourteen converted call sites used+# 180. The three "boot briefly to confirm the install is still usable" steps poll+# for 60s, but they also boot and kill the server in the same shell and keep the+# pid in a local variable, so they are not call sites for this and no --timeout+# flag exists yet to serve them.++set -uo pipefail++# Every converted call site polled for 180s, and studio-ui-smoke.yml carried the+# reason: a cold runner with venv warm-up plus lazy imports has been seen to+# exceed 60s, and failing the wait costs more than waiting two more minutes.+TIMEOUT_SECONDS=180++PORT=""+LOG="logs/studio.log"+TMP="/tmp/health.json"++while [ "$#" -gt 0 ]; do+ case "$1" in+ --port) PORT="$2"; shift 2 ;;+ --log) LOG="$2"; shift 2 ;;+ --tmp) TMP="$2"; shift 2 ;;+ *) echo "wait-for-health.sh: unknown arg '$1'" >&2; exit 2 ;;+ esac+done++[ -n "$PORT" ] || { echo "wait-for-health.sh: --port is required" >&2; exit 2; }++for _ in $(seq 1 "$TIMEOUT_SECONDS"); do+ if curl -fs "http://127.0.0.1:${PORT}/api/health" > "$TMP" \+ && jq -e '.status == "healthy"' "$TMP" > /dev/null; then+ echo "[health] 127.0.0.1:${PORT} reported healthy"+ exit 0+ fi+ sleep 1+done++echo "Unsloth did not become healthy in ${TIMEOUT_SECONDS}s"+if [ -f "$LOG" ]; then+ tail -200 "$LOG"+else+ echo "wait-for-health.sh: no log at '$LOG' to tail" >&2+fi+exit 1diff --git a/.github/workflows/studio-api-smoke.yml b/.github/workflows/studio-api-smoke.ymlindex df9f3807a7b..dc3533f0c83 100644--- a/.github/workflows/studio-api-smoke.yml+++ b/.github/workflows/studio-api-smoke.yml@@ -30,6 +30,8 @@ on:# Every server boot in this workflow shells out to that script, so an edit# to it changes what this workflow actually runs.- '.github/scripts/boot-studio-api-only.sh'+ # Same for the /api/health wait that runs after a boot.+ - '.github/scripts/wait-for-health.sh'# The install step in this workflow is `uses:` on that composite action,# so an edit to the action changes what this workflow actually runs.- '.github/actions/install-unsloth-local/action.yml'@@ -136,13 +138,7 @@ jobs:- name: Wait for /api/healthrun: |- for i in $(seq 1 180); do- if curl -fs "http://127.0.0.1:${STUDIO_PORT}/api/health" > /tmp/health.json; then- jq -e '.status == "healthy"' /tmp/health.json && break- fi- sleep 1- done- jq -e '.status == "healthy"' /tmp/health.json+ bash .github/scripts/wait-for-health.sh --port "$STUDIO_PORT"- name: Pass bootstrap password + rotated targets to the test# The test does its own bootstrap-login + rotation to exercisediff --git a/.github/workflows/studio-inference-smoke.yml b/.github/workflows/studio-inference-smoke.ymlindex 3bb952c6911..423fa1ba102 100644--- a/.github/workflows/studio-inference-smoke.yml+++ b/.github/workflows/studio-inference-smoke.yml@@ -41,6 +41,8 @@ on:# Every server boot in this workflow shells out to that script, so an edit# to it changes what this workflow actually runs.- '.github/scripts/boot-studio-api-only.sh'+ # Same for the /api/health wait that runs after a boot.+ - '.github/scripts/wait-for-health.sh'# The install step in this workflow is `uses:` on that composite action,# so an edit to the action changes what this workflow actually runs.- '.github/actions/install-unsloth-local/action.yml'@@ -150,16 +152,7 @@ jobs:- name: Wait for /api/healthrun: |- for i in $(seq 1 180); do- if curl -fs "http://127.0.0.1:${STUDIO_PORT}/api/health" > /tmp/health.json; then- jq -e '.status == "healthy"' /tmp/health.json- exit 0- fi- sleep 1- done- echo "Unsloth did not become healthy in 180s"- tail -200 logs/studio.log- exit 1+ bash .github/scripts/wait-for-health.sh --port "$STUDIO_PORT"- name: Password rotation (old must fail, new must work)run: |diff --git a/.github/workflows/studio-mac-inference-smoke.yml b/.github/workflows/studio-mac-inference-smoke.ymlindex 316dfb80416..615a2133e97 100644--- a/.github/workflows/studio-mac-inference-smoke.yml+++ b/.github/workflows/studio-mac-inference-smoke.yml@@ -43,6 +43,8 @@ on:# Every server boot in this workflow shells out to that script, so an edit# to it changes what this workflow actually runs.- '.github/scripts/boot-studio-api-only.sh'+ # Same for the /api/health wait that runs after a boot.+ - '.github/scripts/wait-for-health.sh'# The install step in this workflow is `uses:` on that composite action,# so an edit to the action changes what this workflow actually runs.- '.github/actions/install-unsloth-local/action.yml'@@ -214,16 +216,7 @@ jobs:- name: Wait for /api/healthtimeout-minutes: 5run: |- for i in $(seq 1 180); do- if curl -fs "http://127.0.0.1:${STUDIO_PORT}/api/health" > /tmp/health.json; then- jq -e '.status == "healthy"' /tmp/health.json- exit 0- fi- sleep 1- done- echo "Unsloth did not become healthy in 180s"- tail -200 logs/studio.log- exit 1+ bash .github/scripts/wait-for-health.sh --port "$STUDIO_PORT"- name: Password rotation (old must fail, new must work)timeout-minutes: 3diff --git a/.github/workflows/studio-mac-ui-smoke.yml b/.github/workflows/studio-mac-ui-smoke.ymlindex b59c512f5e2..ef8374239f7 100644--- a/.github/workflows/studio-mac-ui-smoke.yml+++ b/.github/workflows/studio-mac-ui-smoke.yml@@ -38,6 +38,8 @@ on:# Every server boot in this workflow shells out to that script, so an edit# to it changes what this workflow actually runs.- '.github/scripts/boot-studio-api-only.sh'+ # Same for the /api/health wait that runs after a boot.+ - '.github/scripts/wait-for-health.sh'# The install step in this workflow is `uses:` on that composite action,# so an edit to the action changes what this workflow actually runs.- '.github/actions/install-unsloth-local/action.yml'@@ -208,13 +210,7 @@ jobs:- name: Wait for /api/healthrun: |- for i in $(seq 1 180); do- if curl -fs "http://127.0.0.1:${STUDIO_PORT}/api/health" > /tmp/health.json; then- jq -e '.status == "healthy"' /tmp/health.json && break- fi- sleep 1- done- jq -e '.status == "healthy"' /tmp/health.json+ bash .github/scripts/wait-for-health.sh --port "$STUDIO_PORT"- name: Pass bootstrap password to the Playwright steprun: |@@ -310,13 +306,8 @@ jobs:- name: Wait for /api/health on 18897run: |- for i in $(seq 1 180); do- if curl -fs "http://127.0.0.1:18897/api/health" > /tmp/health2.json; then- jq -e '.status == "healthy"' /tmp/health2.json && break- fi- sleep 1- done- jq -e '.status == "healthy"' /tmp/health2.json+ bash .github/scripts/wait-for-health.sh \+ --port 18897 --log logs/studio_extra.log --tmp /tmp/health2.json- name: Pass bootstrap pw for extra UI testrun: |@@ -406,13 +397,8 @@ jobs:- name: Wait for /api/health on 18894run: |- for i in $(seq 1 180); do- if curl -fs "http://127.0.0.1:18894/api/health" > /tmp/health_api.json; then- jq -e '.status == "healthy"' /tmp/health_api.json && break- fi- sleep 1- done- jq -e '.status == "healthy"' /tmp/health_api.json+ bash .github/scripts/wait-for-health.sh \+ --port 18894 --log logs/studio_api.log --tmp /tmp/health_api.json- name: Pass bootstrap password + rotated targets to the API testrun: |diff --git a/.github/workflows/studio-ui-smoke.yml b/.github/workflows/studio-ui-smoke.ymlindex abd38c26048..36275c9fc02 100644--- a/.github/workflows/studio-ui-smoke.yml+++ b/.github/workflows/studio-ui-smoke.yml@@ -32,6 +32,8 @@ on:# Every server boot in this workflow shells out to that script, so an edit# to it changes what this workflow actually runs.- '.github/scripts/boot-studio-api-only.sh'+ # Same for the /api/health wait that runs after a boot.+ - '.github/scripts/wait-for-health.sh'# The install step in this workflow is `uses:` on that composite action,# so an edit to the action changes what this workflow actually runs.- '.github/actions/install-unsloth-local/action.yml'@@ -147,17 +149,11 @@ jobs:bash .github/scripts/boot-studio-api-only.sh --port "$STUDIO_PORT"- name: Wait for /api/health- # 180 s -- a cold runner with venv warm-up + lazy imports has- # been seen to exceed 60 s. Failing the wait is more expensive- # than waiting an extra two minutes.+ # The 180 s deadline lives in wait-for-health.sh, along with the+ # reason for it: a cold runner with venv warm-up + lazy imports+ # has been seen to exceed 60 s.run: |- for i in $(seq 1 180); do- if curl -fs "http://127.0.0.1:${STUDIO_PORT}/api/health" > /tmp/health.json; then- jq -e '.status == "healthy"' /tmp/health.json && break- fi- sleep 1- done- jq -e '.status == "healthy"' /tmp/health.json+ bash .github/scripts/wait-for-health.sh --port "$STUDIO_PORT"- name: Pass bootstrap password to the Playwright step# The Playwright test does its OWN /change-password through the@@ -223,13 +219,8 @@ jobs:- name: Wait for /api/health on 18894run: |- for i in $(seq 1 180); do- if curl -fs "http://127.0.0.1:18894/api/health" > /tmp/health2.json; then- jq -e '.status == "healthy"' /tmp/health2.json && break- fi- sleep 1- done- jq -e '.status == "healthy"' /tmp/health2.json+ bash .github/scripts/wait-for-health.sh \+ --port 18894 --log logs/studio_extra.log --tmp /tmp/health2.json- name: Pass bootstrap pw for extra UI testrun: |@@ -280,13 +271,8 @@ jobs:- name: Wait for /api/health on 18898run: |- for i in $(seq 1 180); do- if curl -fs "http://127.0.0.1:18898/api/health" > /tmp/health4.json; then- jq -e '.status == "healthy"' /tmp/health4.json && break- fi- sleep 1- done- jq -e '.status == "healthy"' /tmp/health4.json+ bash .github/scripts/wait-for-health.sh \+ --port 18898 --log logs/studio_modelcfg.log --tmp /tmp/health4.json- name: Pass bootstrap pw for model-config testrun: |@@ -323,13 +309,8 @@ jobs:- name: Wait for /api/health on 18896run: |- for i in $(seq 1 180); do- if curl -fs "http://127.0.0.1:18896/api/health" > /tmp/health3.json; then- jq -e '.status == "healthy"' /tmp/health3.json && break- fi- sleep 1- done- jq -e '.status == "healthy"' /tmp/health3.json+ bash .github/scripts/wait-for-health.sh \+ --port 18896 --log logs/studio_ime.log --tmp /tmp/health3.json- name: Pass bootstrap pw for IME / i18n test# IME smoke does the change-password against the bootstrap thatdiff --git a/.github/workflows/studio-windows-api-smoke.yml b/.github/workflows/studio-windows-api-smoke.ymlindex 665e018103e..6cda60b07db 100644--- a/.github/workflows/studio-windows-api-smoke.yml+++ b/.github/workflows/studio-windows-api-smoke.yml@@ -25,6 +25,8 @@ on:# Every server boot in this workflow shells out to that script, so an edit# to it changes what this workflow actually runs.- '.github/scripts/boot-studio-api-only.sh'+ # Same for the /api/health wait that runs after a boot.+ - '.github/scripts/wait-for-health.sh'push:branches: [main, pip]workflow_dispatch:@@ -203,13 +205,7 @@ jobs:- name: Wait for /api/healthrun: |- for i in $(seq 1 180); do- if curl -fs "http://127.0.0.1:${STUDIO_PORT}/api/health" > /tmp/health.json; then- jq -e '.status == "healthy"' /tmp/health.json && break- fi- sleep 1- done- jq -e '.status == "healthy"' /tmp/health.json+ bash .github/scripts/wait-for-health.sh --port "$STUDIO_PORT"- name: Pass bootstrap password + rotated targets to the testrun: |diff --git a/.github/workflows/studio-windows-inference-smoke.yml b/.github/workflows/studio-windows-inference-smoke.ymlindex 95a8d8e0f7e..1b05e3f11d3 100644--- a/.github/workflows/studio-windows-inference-smoke.yml+++ b/.github/workflows/studio-windows-inference-smoke.yml@@ -39,6 +39,8 @@ on:# Every server boot in this workflow shells out to that script, so an edit# to it changes what this workflow actually runs.- '.github/scripts/boot-studio-api-only.sh'+ # Same for the /api/health wait that runs after a boot.+ - '.github/scripts/wait-for-health.sh'push:branches: [main, pip]workflow_dispatch:@@ -336,16 +338,7 @@ jobs:- name: Wait for /api/healthtimeout-minutes: 10run: |- for i in $(seq 1 180); do- if curl -fs "http://127.0.0.1:${STUDIO_PORT}/api/health" > /tmp/health.json; then- jq -e '.status == "healthy"' /tmp/health.json- exit 0- fi- sleep 1- done- echo "Unsloth did not become healthy in 180s"- tail -200 logs/studio.log- exit 1+ bash .github/scripts/wait-for-health.sh --port "$STUDIO_PORT"- name: Password rotation (old must fail, new must work)timeout-minutes: 3diff --git a/.github/workflows/studio-windows-ui-smoke.yml b/.github/workflows/studio-windows-ui-smoke.ymlindex b87e078fae0..d8464c28420 100644--- a/.github/workflows/studio-windows-ui-smoke.yml+++ b/.github/workflows/studio-windows-ui-smoke.yml@@ -24,6 +24,8 @@ on:# Every server boot in this workflow shells out to that script, so an edit# to it changes what this workflow actually runs.- '.github/scripts/boot-studio-api-only.sh'+ # Same for the /api/health wait that runs after a boot.+ - '.github/scripts/wait-for-health.sh'push:branches: [main, pip]workflow_dispatch:@@ -320,13 +322,7 @@ jobs:- name: Wait for /api/healthrun: |- for i in $(seq 1 180); do- if curl -fs "http://127.0.0.1:${STUDIO_PORT}/api/health" > /tmp/health.json; then- jq -e '.status == "healthy"' /tmp/health.json && break- fi- sleep 1- done- jq -e '.status == "healthy"' /tmp/health.json+ bash .github/scripts/wait-for-health.sh --port "$STUDIO_PORT"- name: Pass bootstrap password to the Playwright steprun: |@@ -372,13 +368,8 @@ jobs:- name: Wait for /api/health on 18897run: |- for i in $(seq 1 180); do- if curl -fs "http://127.0.0.1:18897/api/health" > /tmp/health2.json; then- jq -e '.status == "healthy"' /tmp/health2.json && break- fi- sleep 1- done- jq -e '.status == "healthy"' /tmp/health2.json+ bash .github/scripts/wait-for-health.sh \+ --port 18897 --log logs/studio_extra.log --tmp /tmp/health2.json- name: Pass bootstrap pw for extra UI testrun: |