Pulse/scripts/dev-proxy.sh
Pulse Monitor 40e6ed89a7 chore: reorganize repository structure for better maintainability
- Move development scripts to scripts/ directory (dev.sh, hot-dev.sh, build.sh, etc.)
- Move UPGRADE_NOTICE to docs/ directory
- Remove empty 2025-08-14 file
- Update all references to moved scripts in documentation
2025-08-18 21:57:40 +00:00

73 lines
No EOL
1.5 KiB
Bash
Executable file

#!/bin/bash
# Development setup with hot-reload
# Frontend runs on Vite dev server with hot-reload
# Backend runs separately, frontend proxies API calls to it
echo "Starting Pulse development environment with hot-reload..."
echo "Frontend will be available at http://localhost:5173 with instant updates"
echo "Press Ctrl+C to stop"
# Kill any existing processes
pkill -f "vite" 2>/dev/null
pkill -f "pulse" 2>/dev/null
# Start backend in background
echo "Starting backend..."
cd /opt/pulse
go build -o pulse ./cmd/pulse
./pulse &
BACKEND_PID=$!
# Start frontend dev server with hot-reload
echo "Starting frontend with hot-reload..."
cd /opt/pulse/frontend-modern
# Update vite config to proxy API calls to backend
cat > vite.config.ts.tmp << 'EOF'
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import path from 'path';
export default defineConfig({
plugins: [solidPlugin()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
port: 5173,
proxy: {
'/api': {
target: 'http://localhost:7655',
changeOrigin: true,
},
'/ws': {
target: 'ws://localhost:7655',
ws: true,
},
},
},
});
EOF
mv vite.config.ts vite.config.ts.bak
mv vite.config.ts.tmp vite.config.ts
# Cleanup function
cleanup() {
echo "Stopping services..."
kill $BACKEND_PID 2>/dev/null
pkill -f "vite" 2>/dev/null
mv vite.config.ts.bak vite.config.ts 2>/dev/null
exit
}
trap cleanup INT TERM
# Start vite dev server
npm run dev &
# Wait
wait