#!/bin/sh set -e # Seed content into the volume if it's empty (first deploy). SEED_DIR="/app/content-seed" CONTENT_DIR="/app/content" if [ -d "$SEED_DIR" ] && [ -d "$CONTENT_DIR" ]; then if [ ! -d "$CONTENT_DIR/sections" ] || [ -z "$(ls -A "$CONTENT_DIR/sections" 2>/dev/null)" ]; then echo "Seeding content from $SEED_DIR into $CONTENT_DIR..." cp -rn "$SEED_DIR/"* "$CONTENT_DIR/" 2>/dev/null || true echo "Content seeded." fi fi echo "Starting orchestrator on port ${ORCHESTRATOR_PORT:-3001}..." node --import tsx/esm /app/server/src/index.ts & ORCH_PID=$! echo "Starting Astro SSR on port ${PORT:-4321}..." node /app/dist/server/entry.mjs & ASTRO_PID=$! # Shut down both on any signal trap "kill $ORCH_PID $ASTRO_PID 2>/dev/null; wait; exit 0" SIGTERM SIGINT # Wait for either to exit — if one dies, stop both wait -n $ORCH_PID $ASTRO_PID 2>/dev/null EXIT_CODE=$? echo "A process exited with code $EXIT_CODE, shutting down..." kill $ORCH_PID $ASTRO_PID 2>/dev/null wait exit $EXIT_CODE