#!/usr/bin/env bash # # Local dev: API server + v2client (Vue 3 / Vite). # Run from inside nix-shell, which provides node/pnpm/pm2/mariadb, # starts the local MySQL, and exports DB_* and JSON_KEY. # # Unlike startDevServerAndClient.sh (remote dev box, /home/mab/ss, Vue 2 # client) this is path-relative. set -euo pipefail REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$REPO" if [ -z "${JSON_KEY:-}" ]; then echo "JSON_KEY is not set -- run this from inside nix-shell." >&2 exit 1 fi if ! mysqladmin --socket="$REPO/.mysql/mysql.sock" ping &>/dev/null; then echo "Local MySQL is not running -- run this from inside nix-shell." >&2 exit 1 fi echo '::--:: Starting API server (:3000) + socket.io (:3001) under pm2...' cd "$REPO/server" # `env -u name`: nix's mkShell exports its `name` attr ("Solid Scribe Env") # as $name, and pm2 uses $name to override the app name from ecosystem.config.js. pm2 delete NoteServer &>/dev/null || true pm2 flush &>/dev/null || true # --watch is a dev-only convenience; ecosystem.config.js leaves it off so a # production `git pull` can't restart the server mid-update. env -u name pm2 start ecosystem.config.js --watch cd "$REPO" echo '::--:: Starting v2client dev server -> http://localhost:5173' cd "$REPO/client" [ -d node_modules ] || pnpm install screen -S "V2ClientScreen" -X quit &>/dev/null || true screen -dmS "V2ClientScreen" bash -c "cd '$REPO/client'; pnpm dev" cat < :3000, /socket -> :3001) api http://localhost:3000 logs pm2 logs NoteServer screen -r V2ClientScreen (detach: ctrl-a d) stop pm2 delete NoteServer; screen -S V2ClientScreen -X quit MSG