Files
rustycms/dev.sh
Peter Meier 1db203841d
All checks were successful
Deploy to Server / deploy (push) Successful in 22s
Add sync.sh for content sync between local and server
- pull: server → local
- push: local → server
- watch: auto-push on file changes via fswatch
- status: dry-run diff
- dev.sh: ./dev.sh --sync pulls before starting

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-15 22:50:13 +01:00

79 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Start RustyCMS API + Admin UI and open browser
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Cleanup on exit
cleanup() {
echo "Shutting down..."
kill 0 2>/dev/null || true
}
trap cleanup EXIT INT TERM
# Optional: sync content from server
if [ "${SYNC:-}" = "1" ] || [ "${1:-}" = "--sync" ]; then
echo "Syncing content from server..."
./sync.sh pull
fi
# Start API in background
echo "Starting RustyCMS API on http://127.0.0.1:3000 ..."
cargo run &
API_PID=$!
# Wait for API to be ready
echo "Waiting for API..."
for i in {1..30}; do
if curl -s http://127.0.0.1:3000/health >/dev/null 2>&1; then
echo "API is ready."
break
fi
sleep 0.5
if ! kill -0 $API_PID 2>/dev/null; then
echo "API failed to start." >&2
exit 1
fi
done
# Ensure admin-ui dependencies are up to date
echo "Installing Admin UI dependencies..."
(cd admin-ui && npm install)
# Start Admin UI in background
echo "Starting Admin UI on http://localhost:2001 ..."
(cd admin-ui && npm run dev) &
UI_PID=$!
# Wait for Admin UI to be ready
echo "Waiting for Admin UI..."
for i in {1..30}; do
if curl -s http://localhost:2001 >/dev/null 2>&1; then
echo "Admin UI is ready."
break
fi
sleep 0.5
if ! kill -0 $UI_PID 2>/dev/null; then
echo "Admin UI failed to start." >&2
exit 1
fi
done
# Open browser
if command -v open >/dev/null 2>&1; then
open http://localhost:2001
elif command -v xdg-open >/dev/null 2>&1; then
xdg-open http://localhost:2001
else
echo "Open http://localhost:2001 in your browser."
fi
echo ""
echo "RustyCMS running:"
echo " API: http://127.0.0.1:3000"
echo " Admin UI: http://localhost:2001"
echo ""
echo "Press Ctrl+C to stop both."
wait