Lab bootstrap scripts exercise CRM PHP, Node redirector, health endpoints, and MySQL analytics on 10.10.50.17. Bearer auth is checked before session dev-login; redirector reads CRM_API_URL at fetch time so dotenv applies correctly. Paperclip-Task: BIT-24693 Paperclip-Run: 3467cbf0-a91f-4cb0-808a-ccb043de28d3 Co-authored-by: Cursor <[email protected]>
65 lines
1.7 KiB
Bash
Executable File
65 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Start MoneyFlix lab services (CRM PHP + Node redirector)
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
ENV_FILE="${MONEYFLIX_LAB_ENV:-$ROOT/.env.lab}"
|
|
PID_DIR="$ROOT/tools/lab/.pids"
|
|
LOG_DIR="$ROOT/tools/lab/.logs"
|
|
|
|
mkdir -p "$PID_DIR" "$LOG_DIR"
|
|
|
|
if [[ ! -f "$ENV_FILE" ]]; then
|
|
echo "Run bootstrap first: bash tools/lab/bootstrap.sh" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# shellcheck disable=SC1090
|
|
source "$ENV_FILE"
|
|
|
|
stop_if_running() {
|
|
local name=$1
|
|
local pidfile="$PID_DIR/$name.pid"
|
|
if [[ -f "$pidfile" ]]; then
|
|
local pid
|
|
pid="$(cat "$pidfile")"
|
|
if kill -0 "$pid" 2>/dev/null; then
|
|
echo "Stopping existing $name (pid $pid)"
|
|
kill "$pid" 2>/dev/null || true
|
|
sleep 1
|
|
fi
|
|
rm -f "$pidfile"
|
|
fi
|
|
}
|
|
|
|
stop_if_running crm
|
|
stop_if_running redirector
|
|
|
|
echo "Starting CRM on :${CRM_PORT}..."
|
|
php -S "127.0.0.1:${CRM_PORT}" -t "$ROOT/crm" "$ROOT/crm/index.php" \
|
|
> "$LOG_DIR/crm.log" 2>&1 &
|
|
echo $! > "$PID_DIR/crm.pid"
|
|
|
|
echo "Starting redirector on :${REDIRECTOR_PORT}..."
|
|
(cd "$ROOT/nodejs-redirector" && node index.mjs) > "$LOG_DIR/redirector.log" 2>&1 &
|
|
echo $! > "$PID_DIR/redirector.pid"
|
|
|
|
sleep 3
|
|
|
|
if ! kill -0 "$(cat "$PID_DIR/crm.pid")" 2>/dev/null; then
|
|
echo "CRM failed to start — see $LOG_DIR/crm.log" >&2
|
|
tail -30 "$LOG_DIR/crm.log" >&2 || true
|
|
exit 1
|
|
fi
|
|
|
|
if ! kill -0 "$(cat "$PID_DIR/redirector.pid")" 2>/dev/null; then
|
|
echo "Redirector failed to start — see $LOG_DIR/redirector.log" >&2
|
|
tail -30 "$LOG_DIR/redirector.log" >&2 || true
|
|
exit 1
|
|
fi
|
|
|
|
echo "Lab stack running:"
|
|
echo " CRM: http://127.0.0.1:${CRM_PORT}/system/status"
|
|
echo " Redirector: http://127.0.0.1:${REDIRECTOR_PORT}/health"
|
|
echo " Logs: $LOG_DIR/"
|