Pulse/hot-dev.sh
Pulse Monitor 66403e88fb refactor: consolidate authentication system and improve API structure
- Remove registration tokens feature in favor of simpler API token auth
- Add password authentication with change password functionality
- Centralize API client logic with proper auth handling
- Add development scripts for better DX (hot-reload, proxy setup)
- Refactor auth middleware and handlers for cleaner separation
- Update frontend to use new centralized API client
2025-08-13 14:51:46 +00:00

85 lines
No EOL
2 KiB
Bash
Executable file

#!/bin/bash
# Hot-reload development setup
# Frontend runs on Vite dev server on port 7655 with instant hot-reload
# Backend API runs on port 7656 (one port up)
# Just change frontend code and see changes instantly!
echo "========================================="
echo "Starting HOT-RELOAD development mode"
echo "========================================="
echo ""
echo "Frontend: http://192.168.0.123:7655 (with hot-reload)"
echo "Backend API: http://localhost:7656"
echo ""
echo "Just edit frontend files and see changes instantly!"
echo "Press Ctrl+C to stop"
echo "========================================="
# Kill any existing Pulse processes
sudo systemctl stop pulse-backend 2>/dev/null
pkill -f "pulse" 2>/dev/null
# Start backend on port 7656 (one port up from normal)
echo "Starting backend on port 7656..."
cd /opt/pulse
if [ ! -f pulse ] || [ pulse -ot cmd/pulse/main.go ]; then
echo "Building backend..."
go build -o pulse ./cmd/pulse
fi
PORT=7656 ./pulse &
BACKEND_PID=$!
# Wait for backend to start
sleep 2
# Create temporary vite config for development
cd /opt/pulse/frontend-modern
cat > vite.config.dev.ts << 'EOF'
import { defineConfig } from 'vite';
import solid from 'vite-plugin-solid';
import path from 'path';
export default defineConfig({
plugins: [solid()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
port: 7655,
host: '0.0.0.0',
proxy: {
'/api': {
target: 'http://127.0.0.1:7656',
changeOrigin: true,
},
'/ws': {
target: 'ws://127.0.0.1:7656',
ws: true,
changeOrigin: true,
},
},
},
build: {
target: 'esnext',
},
});
EOF
# Cleanup on exit
cleanup() {
echo ""
echo "Stopping services..."
kill $BACKEND_PID 2>/dev/null
rm -f vite.config.dev.ts
exit
}
trap cleanup INT TERM
# Start vite dev server with hot-reload
echo "Starting frontend with hot-reload on port 7655..."
npx vite --config vite.config.dev.ts --clearScreen false
cleanup