Pulse/scripts/hot-dev.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

86 lines
No EOL
2.1 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 (but NOT ttyd/tmux which run Claude Code!)
sudo systemctl stop pulse-backend 2>/dev/null
# Use exact match to only kill the "pulse" binary, not processes running FROM /opt/pulse
pkill -x "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