#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")" PID_FILE=".demo.pid" LOG_FILE=".demo.log" if [ -f "$PID_FILE" ]; then existing="$(cat "$PID_FILE")" if [ -n "$existing" ] && kill -0 "$existing" 2>/dev/null; then echo "crema-app-aifirst-template already running (pid $existing)" exit 0 fi rm -f "$PID_FILE" fi nohup npm run dev >"$LOG_FILE" 2>&1 & pid=$! echo "$pid" >"$PID_FILE" disown "$pid" 2>/dev/null || true echo "crema-app-aifirst-template started (pid $pid) — logs: $LOG_FILE"