fix(dev-start): detect missing Go and fall back to docker-compose platform
Issue: scripts/dev-start.sh assumed `go` was on PATH; on a fresh dev box without Go installed, line 111 (`go run ./cmd/server`) failed with `go: not found` and the script bailed before printing the readiness banner. The script's own prerequisite list (line 13-21) said "Go 1.25+" but there was no signpost between "open the doc" and "command not found." Fix: detect `go` via `command -v`. If present, keep the existing `go run` path (fast iteration, attaches to local log). If not, fall back to `docker compose up -d --build platform` which uses the published platform container — slower first run but the script still works without forcing the dev to install Go just to read logs. Either path leaves /health on :8080 so the rest of the script's wait loop is unchanged. If both paths fail, the error message names the install URL (https://go.dev/dl/) and the fallback diagnostic (`/tmp/molecule-platform.log`) so the dev has a single, actionable next step. Verified: `sh -n` syntax check passes. Closes #2329 item 2.
This commit is contained in:
parent
16796431b9
commit
88da3d523b
@ -105,11 +105,43 @@ echo "==> Running infra/scripts/setup.sh (infra + template registry)"
|
||||
"$ROOT/infra/scripts/setup.sh"
|
||||
|
||||
# ─────────────────────────────────────────────── 3. platform
|
||||
#
|
||||
# Two paths:
|
||||
# (a) `go` is on PATH → run the platform directly via `go run`.
|
||||
# Fast iteration, attaches to /tmp/molecule-platform.log.
|
||||
# (b) `go` is NOT on PATH → fall back to the published platform
|
||||
# container image. Slower first run (image pull) but the script
|
||||
# still works on a fresh dev box without forcing the dev to
|
||||
# install Go just to read logs.
|
||||
#
|
||||
# The earlier version of this script silently called `go run` and died
|
||||
# with `go: not found` on dev boxes where Go wasn't installed; the
|
||||
# script's own prerequisite list (line 13-21) said "Go 1.25+" but the
|
||||
# user had no signpost between "open the doc" and "command not found
|
||||
# at line 111." This branch makes the failure path either succeed
|
||||
# (fallback) or fail loud with explicit install guidance.
|
||||
|
||||
echo "==> Starting Platform (Go :8080)"
|
||||
cd "$ROOT/workspace-server"
|
||||
go run ./cmd/server > /tmp/molecule-platform.log 2>&1 &
|
||||
PLATFORM_PID=$!
|
||||
if command -v go >/dev/null 2>&1; then
|
||||
echo "==> Starting Platform (Go :8080)"
|
||||
cd "$ROOT/workspace-server"
|
||||
go run ./cmd/server > /tmp/molecule-platform.log 2>&1 &
|
||||
PLATFORM_PID=$!
|
||||
else
|
||||
echo "==> Go not found on PATH — falling back to docker-compose platform service"
|
||||
echo " (Install Go 1.25+ for faster iteration: https://go.dev/dl/)"
|
||||
cd "$ROOT"
|
||||
# Bring up just the platform service from docker-compose.yml. infra/setup.sh
|
||||
# already brought up postgres+redis+etc on docker-compose.infra.yml; this
|
||||
# adds the platform container on top, mapped to :8080 so the rest of this
|
||||
# script's wait-for-/health loop works unchanged.
|
||||
docker compose up -d --build platform > /tmp/molecule-platform.log 2>&1 || {
|
||||
echo " ✗ docker compose up platform failed — see /tmp/molecule-platform.log"
|
||||
echo " Either install Go 1.25+ (https://go.dev/dl/) and rerun, or fix the docker fallback."
|
||||
exit 1
|
||||
}
|
||||
# PLATFORM_PID is unset on this path; cleanup() handles that with `kill ... 2>/dev/null || true`.
|
||||
PLATFORM_PID=
|
||||
fi
|
||||
|
||||
echo " Waiting for Platform /health..."
|
||||
PLATFORM_READY=0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user