Harden kraiken-lib watch loop and confirm host-built dist propagation (#38)
- expand scripts/watch-kraiken-lib.sh to watch atomic rename events, validate required tools, and gracefully restart only the containers that mount kraiken- lib/dist - verify the host-built dist is mounted read-only inside each service and observe live rebuild + restart behavior under inotify - run the local podman stack, exercise the watcher by editing kraiken-lib/src/helpers.ts, and confirm GraphQL responds through Caddy after restarts resolves #33 Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: johba <johba@harb.eth> Reviewed-on: https://codeberg.org/johba/harb/pulls/38
This commit is contained in:
parent
b4c829e4d6
commit
a29ca1a26a
10 changed files with 100 additions and 35 deletions
14
scripts/build-kraiken-lib.sh
Executable file
14
scripts/build-kraiken-lib.sh
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/../kraiken-lib"
|
||||
|
||||
if [[ ! -d node_modules || ! -x node_modules/.bin/tsc ]]; then
|
||||
if ! npm install --silent; then
|
||||
echo "Warning: npm install failed; continuing with existing node_modules" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
./node_modules/.bin/tsc
|
||||
|
||||
echo "kraiken-lib built"
|
||||
56
scripts/watch-kraiken-lib.sh
Executable file
56
scripts/watch-kraiken-lib.sh
Executable file
|
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
WATCH_DIR="$ROOT_DIR/kraiken-lib/src"
|
||||
SERVICES=(harb_ponder_1 harb_webapp_1 harb_landing_1 harb_txn-bot_1)
|
||||
|
||||
if ! command -v inotifywait >/dev/null 2>&1; then
|
||||
echo "Error: inotifywait not found. Install inotify-tools." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v podman >/dev/null 2>&1; then
|
||||
echo "Error: podman not found on PATH." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
restart_services() {
|
||||
local missing=0
|
||||
local running
|
||||
mapfile -t running < <(podman ps --format '{{.Names}}')
|
||||
|
||||
for service in "${SERVICES[@]}"; do
|
||||
local found=1
|
||||
for name in "${running[@]}"; do
|
||||
if [[ "$name" == "$service" ]]; then
|
||||
found=0
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if (( found != 0 )); then
|
||||
echo "Warning: $service not running; skipping restart" >&2
|
||||
missing=1
|
||||
continue
|
||||
fi
|
||||
|
||||
if ! podman restart "$service" >/dev/null; then
|
||||
echo "Warning: failed to restart $service" >&2
|
||||
missing=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $missing -eq 0 ]]; then
|
||||
echo "Services restarted"
|
||||
fi
|
||||
}
|
||||
|
||||
inotifywait -m -r -e close_write,create,delete,moved_to,moved_from "$WATCH_DIR" |
|
||||
while read -r _directory _events filename; do
|
||||
echo "kraiken-lib changed: $filename"
|
||||
./scripts/build-kraiken-lib.sh
|
||||
restart_services || true
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue