mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-11 14:00:29 +00:00
Remove deprecated configuration and startup files
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
# Development Environment Configuration
|
||||
|
||||
# Mock Data Configuration
|
||||
USE_MOCK_DATA=true
|
||||
MOCK_DATA_ENABLED=true
|
||||
|
||||
# Mock Cluster Configuration
|
||||
MOCK_CLUSTER_ENABLED=true
|
||||
MOCK_CLUSTER_NAME=mock-proxmox-cluster
|
||||
|
||||
# App Configuration
|
||||
PORT=7654
|
||||
LOG_LEVEL=debug # More verbose logging for development
|
||||
ENABLE_DEV_TOOLS=true
|
||||
METRICS_HISTORY_MINUTES=60
|
||||
|
||||
# SSL Configuration
|
||||
IGNORE_SSL_ERRORS=true
|
||||
NODE_TLS_REJECT_UNAUTHORIZED=0
|
||||
|
||||
# Polling Intervals (in milliseconds) - faster for development
|
||||
NODE_POLLING_INTERVAL_MS=1000
|
||||
EVENT_POLLING_INTERVAL_MS=1000
|
||||
@@ -1,23 +0,0 @@
|
||||
# Development Environment Configuration
|
||||
|
||||
# Mock Data Configuration
|
||||
USE_MOCK_DATA=true
|
||||
MOCK_DATA_ENABLED=true
|
||||
|
||||
# Mock Cluster Configuration
|
||||
MOCK_CLUSTER_ENABLED=true
|
||||
MOCK_CLUSTER_NAME=mock-proxmox-cluster
|
||||
|
||||
# App Configuration
|
||||
PORT=7654
|
||||
LOG_LEVEL=debug # More verbose logging for development
|
||||
ENABLE_DEV_TOOLS=true
|
||||
METRICS_HISTORY_MINUTES=60
|
||||
|
||||
# SSL Configuration
|
||||
IGNORE_SSL_ERRORS=true
|
||||
NODE_TLS_REJECT_UNAUTHORIZED=0
|
||||
|
||||
# Polling Intervals (in milliseconds) - faster for development
|
||||
NODE_POLLING_INTERVAL_MS=1000
|
||||
EVENT_POLLING_INTERVAL_MS=1000
|
||||
@@ -1,46 +0,0 @@
|
||||
# Production Environment Configuration
|
||||
|
||||
# Mock Data Configuration - disabled for production
|
||||
USE_MOCK_DATA=false
|
||||
MOCK_DATA_ENABLED=false
|
||||
|
||||
# Proxmox Node Configuration
|
||||
# Node 1
|
||||
PROXMOX_NODE_1_NAME=your-node-name
|
||||
PROXMOX_NODE_1_HOST=https://your-proxmox-ip:8006
|
||||
PROXMOX_NODE_1_TOKEN_ID=your-token-id
|
||||
PROXMOX_NODE_1_TOKEN_SECRET=your-token-secret
|
||||
|
||||
# Node 2 (optional)
|
||||
PROXMOX_NODE_2_NAME=your-node-name-2
|
||||
PROXMOX_NODE_2_HOST=https://your-proxmox-ip-2:8006
|
||||
PROXMOX_NODE_2_TOKEN_ID=your-token-id
|
||||
PROXMOX_NODE_2_TOKEN_SECRET=your-token-secret
|
||||
|
||||
# Node 3 (optional)
|
||||
PROXMOX_NODE_3_NAME=your-node-name-3
|
||||
PROXMOX_NODE_3_HOST=https://your-proxmox-ip-3:8006
|
||||
PROXMOX_NODE_3_TOKEN_ID=your-token-id
|
||||
PROXMOX_NODE_3_TOKEN_SECRET=your-token-secret
|
||||
|
||||
# App Configuration
|
||||
PORT=7654
|
||||
|
||||
# Environment Configuration
|
||||
NODE_ENV=production
|
||||
LOG_LEVEL=info
|
||||
ENABLE_DEV_TOOLS=false
|
||||
METRICS_HISTORY_MINUTES=60
|
||||
|
||||
# SSL Configuration
|
||||
IGNORE_SSL_ERRORS=true
|
||||
NODE_TLS_REJECT_UNAUTHORIZED=0
|
||||
|
||||
# Polling Intervals (in milliseconds)
|
||||
NODE_POLLING_INTERVAL_MS=5000
|
||||
EVENT_POLLING_INTERVAL_MS=5000
|
||||
|
||||
# API Configuration
|
||||
API_TIMEOUT_MS=60000
|
||||
API_RETRY_DELAY_MS=5000
|
||||
API_RETRY_ATTEMPTS=3
|
||||
-108
@@ -1,108 +0,0 @@
|
||||
# Frontend build stage
|
||||
FROM node:18-slim AS frontend-builder
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
# Copy frontend package files for dependency caching
|
||||
COPY frontend/package*.json ./
|
||||
|
||||
# Install frontend dependencies
|
||||
RUN npm ci
|
||||
|
||||
# Copy frontend source files
|
||||
COPY frontend/src ./src
|
||||
COPY frontend/index.html ./
|
||||
COPY frontend/vite.config.js ./
|
||||
COPY public ./public
|
||||
|
||||
# Build the frontend
|
||||
RUN npm run build
|
||||
|
||||
# Backend build stage
|
||||
FROM node:18-slim AS backend-builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies for canvas
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
python3 \
|
||||
python-is-python3 \
|
||||
make \
|
||||
g++ \
|
||||
build-essential \
|
||||
libcairo2-dev \
|
||||
libpango1.0-dev \
|
||||
libjpeg-dev \
|
||||
libgif-dev \
|
||||
librsvg2-dev \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy package files for dependency caching
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci
|
||||
|
||||
# Copy backend source files
|
||||
COPY src ./src
|
||||
COPY tsconfig*.json ./
|
||||
|
||||
# Build the backend
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM node:18-slim
|
||||
|
||||
# Add metadata
|
||||
LABEL version="1.5.4"
|
||||
LABEL description="Pulse - A lightweight monitoring application for Proxmox VE"
|
||||
LABEL maintainer="Richard Courtman <richard@courtman.me>"
|
||||
|
||||
# Install runtime dependencies for canvas and create a non-root user
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
dumb-init \
|
||||
python3 \
|
||||
python-is-python3 \
|
||||
make \
|
||||
g++ \
|
||||
build-essential \
|
||||
pkg-config \
|
||||
libpixman-1-dev \
|
||||
libcairo2-dev \
|
||||
libpango1.0-dev \
|
||||
libjpeg-dev \
|
||||
libgif-dev \
|
||||
librsvg2-dev \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& groupadd -r pulse && useradd -r -g pulse pulse
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy only production dependencies
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
# Copy built files from builder stages
|
||||
COPY --from=backend-builder /app/dist ./dist
|
||||
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
|
||||
|
||||
# Create logs directory with proper permissions
|
||||
RUN mkdir -p /app/logs && chown -R pulse:pulse /app/logs
|
||||
|
||||
# Set environment variables
|
||||
ENV PORT=7654
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Switch to non-root user
|
||||
USER pulse
|
||||
|
||||
# Expose the backend port
|
||||
EXPOSE 7654
|
||||
|
||||
# Use dumb-init to handle signals properly
|
||||
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
||||
|
||||
# Start the application
|
||||
CMD ["node", "dist/server.js"]
|
||||
@@ -1,62 +0,0 @@
|
||||
FROM node:18-slim
|
||||
|
||||
# Install dependencies for canvas and development tools
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
python3 \
|
||||
python-is-python3 \
|
||||
make \
|
||||
g++ \
|
||||
build-essential \
|
||||
libcairo2-dev \
|
||||
libpango1.0-dev \
|
||||
libjpeg-dev \
|
||||
libgif-dev \
|
||||
librsvg2-dev \
|
||||
procps \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files for dependency installation
|
||||
COPY package*.json ./
|
||||
COPY frontend/package*.json ./frontend/
|
||||
|
||||
# Install backend dependencies and global development tools
|
||||
RUN npm install
|
||||
RUN npm install -g ts-node-dev ts-node
|
||||
|
||||
# Install frontend dependencies
|
||||
WORKDIR /app/frontend
|
||||
RUN npm install
|
||||
|
||||
# Return to app directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy necessary configuration files
|
||||
COPY tsconfig*.json ./
|
||||
COPY frontend/vite.config.js ./frontend/
|
||||
COPY frontend/index.html ./frontend/
|
||||
COPY scripts ./scripts
|
||||
COPY frontend/src ./frontend/src
|
||||
COPY src ./src
|
||||
|
||||
# Create logs directory
|
||||
RUN mkdir -p /app/logs
|
||||
|
||||
# Create a script to start both servers
|
||||
RUN echo '#!/bin/sh\n\
|
||||
# Start mock server\n\
|
||||
ts-node src/mock/run-server.ts > /tmp/pulse-mock-server.log 2>&1 & \n\
|
||||
sleep 2\n\
|
||||
# Start backend server\n\
|
||||
ts-node-dev --respawn --transpile-only src/server.ts & \n\
|
||||
# Start frontend server\n\
|
||||
cd /app/frontend && npm run dev -- --port 3000 --host 0.0.0.0\n' > /app/start-dev.sh && \
|
||||
chmod +x /app/start-dev.sh
|
||||
|
||||
# Expose ports for backend, frontend, and mock server
|
||||
EXPOSE 7654 3000 7655
|
||||
|
||||
# Start development servers with hot-reloading
|
||||
CMD ["/app/start-dev.sh"]
|
||||
@@ -1,118 +0,0 @@
|
||||
# Pulse Mock Data Setup
|
||||
|
||||
This guide explains how to run Pulse with mock data instead of connecting to real Proxmox servers.
|
||||
|
||||
## Quick Start
|
||||
|
||||
There are several ways to start Pulse with mock data:
|
||||
|
||||
### Option 1: Using the dev:mock script (Recommended)
|
||||
|
||||
```bash
|
||||
npm run dev:mock
|
||||
```
|
||||
|
||||
This script follows the same pattern as the standard `dev:start` script but uses mock data instead of real Proxmox servers. It:
|
||||
|
||||
1. Kills any existing servers running on the required ports
|
||||
2. Starts the mock data server
|
||||
3. Starts the backend server with mock data enabled
|
||||
4. Starts the frontend with mock data enabled
|
||||
|
||||
When you exit the frontend (Ctrl+C), it will automatically kill the backend and mock data servers.
|
||||
|
||||
### Option 2: Using the dev script
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
This will:
|
||||
1. Start the mock data server
|
||||
2. Start the backend server with mock data enabled
|
||||
3. Start the frontend with mock data enabled
|
||||
|
||||
## What's Happening Behind the Scenes
|
||||
|
||||
The mock data setup:
|
||||
|
||||
1. Sets the necessary environment variables:
|
||||
- `NODE_ENV=development`
|
||||
- `USE_MOCK_DATA=true`
|
||||
- `MOCK_DATA_ENABLED=true`
|
||||
|
||||
2. Starts the mock data server (`src/mock/server.ts`)
|
||||
- This server runs on port 7655
|
||||
- It generates simulated Proxmox data with realistic VM and container names
|
||||
|
||||
3. Starts the backend server with mock data enabled
|
||||
- The backend connects to the mock data server instead of real Proxmox servers
|
||||
- It uses the `MockClient` class to handle communication with the mock server
|
||||
|
||||
4. Starts the frontend with mock data enabled
|
||||
- The frontend connects to the backend as usual
|
||||
|
||||
## Mock Data Architecture
|
||||
|
||||
The mock data implementation consists of several components:
|
||||
|
||||
1. **Mock Templates** (`src/mock/templates.ts`)
|
||||
- Contains templates for VM and container names and OS types
|
||||
- Used by both the mock client and mock server
|
||||
|
||||
2. **Mock Server** (`src/mock/server.ts`)
|
||||
- Standalone server that generates and serves mock data
|
||||
- Runs on port 7655
|
||||
- Provides realistic VM and container data with meaningful names
|
||||
|
||||
3. **Mock Client** (`src/api/mock-client.ts`)
|
||||
- Implements the same interface as the real Proxmox client
|
||||
- Connects to the mock server instead of real Proxmox servers
|
||||
- Generates its own mock VMs and containers with meaningful names
|
||||
|
||||
## Customizing Mock Data
|
||||
|
||||
If you want to customize the mock data:
|
||||
|
||||
1. Edit the `src/mock/templates.ts` file
|
||||
- Modify the VM and container templates to add or change the available names and OS types
|
||||
|
||||
2. Edit the `src/mock/server.ts` file
|
||||
- Modify the data generation functions to create the data you need
|
||||
|
||||
3. Restart the mock server
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If you encounter issues:
|
||||
|
||||
1. Check the mock server logs: `/tmp/pulse-mock-server.log`
|
||||
2. Make sure all required ports are available:
|
||||
- 7654 (backend server)
|
||||
- 7655 (mock data server)
|
||||
- 3000 (frontend)
|
||||
|
||||
3. If needed, kill existing processes:
|
||||
```bash
|
||||
npm run dev:kill:all
|
||||
```
|
||||
|
||||
4. If you get a "ts-node: command not found" error:
|
||||
```bash
|
||||
npm install -g ts-node
|
||||
```
|
||||
|
||||
5. If you encounter TypeScript errors in the mock server:
|
||||
- Make sure all variables have proper type definitions
|
||||
- Check the `src/mock/server.ts` file for any type errors
|
||||
- Run `tsc --noEmit src/mock/server.ts` to check for type errors without compiling
|
||||
|
||||
## Switching Back to Real Data
|
||||
|
||||
To switch back to using real Proxmox servers:
|
||||
|
||||
1. Configure your `.env` file with real Proxmox server details
|
||||
2. Start the application normally:
|
||||
```bash
|
||||
npm run dev:start
|
||||
```
|
||||
@@ -1,35 +0,0 @@
|
||||
services:
|
||||
pulse-app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.dev
|
||||
container_name: pulse-app
|
||||
ports:
|
||||
- "7654:7654" # Backend API
|
||||
- "3000:3000" # Frontend dev server
|
||||
- "7655:7655" # Mock data server
|
||||
volumes:
|
||||
- ./src:/app/src
|
||||
- ./frontend/src:/app/frontend/src
|
||||
- ./frontend/public:/app/frontend/public
|
||||
- ./frontend/index.html:/app/frontend/index.html
|
||||
- ./frontend/vite.config.js:/app/frontend/vite.config.js
|
||||
- ./scripts:/app/scripts
|
||||
- ./logs:/app/logs
|
||||
env_file:
|
||||
- .env.development
|
||||
environment:
|
||||
- LOG_LEVEL=debug
|
||||
- NODE_OPTIONS=--no-warnings
|
||||
- SUPPRESS_NO_CONFIG_WARNING=true
|
||||
- VITE_API_URL=http://localhost:7654
|
||||
- USE_MOCK_DATA=true
|
||||
- MOCK_DATA_ENABLED=true
|
||||
- DOCKER_CONTAINER=true
|
||||
command: /app/start-dev.sh
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "1m"
|
||||
max-file: "1"
|
||||
restart: unless-stopped
|
||||
@@ -1,23 +0,0 @@
|
||||
services:
|
||||
pulse-app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: pulse-app-prod
|
||||
ports:
|
||||
- "7654:7654" # Production server
|
||||
volumes:
|
||||
- ./logs:/app/logs
|
||||
env_file:
|
||||
- .env.production
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- LOG_LEVEL=info
|
||||
- USE_MOCK_DATA=false
|
||||
- MOCK_DATA_ENABLED=false
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
restart: unless-stopped
|
||||
@@ -1,38 +0,0 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
REM Stop any running Pulse Docker containers first
|
||||
echo Stopping any running Pulse Docker containers...
|
||||
where docker >nul 2>&1
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
for /f "tokens=*" %%i in ('docker ps -q --filter "name=pulse"') do (
|
||||
docker stop %%i
|
||||
)
|
||||
) else (
|
||||
echo Docker not found, skipping container cleanup...
|
||||
)
|
||||
|
||||
REM Kill any existing servers
|
||||
echo Killing any existing servers...
|
||||
taskkill /f /im "node.exe" /fi "WINDOWTITLE eq node dist/server.js" 2>nul
|
||||
call npx kill-port 7654 3000
|
||||
|
||||
REM Set environment to development
|
||||
set NODE_ENV=development
|
||||
|
||||
REM Start the real backend server
|
||||
echo Starting real backend server...
|
||||
start /b cmd /c "npm run dev:server"
|
||||
|
||||
REM Wait a moment for the server to start
|
||||
timeout /t 3 /nobreak > nul
|
||||
|
||||
REM Set host IP to bind to all interfaces
|
||||
set HOST_IP=0.0.0.0
|
||||
|
||||
REM Start the frontend Vite dev server
|
||||
echo Starting Pulse interface...
|
||||
cd frontend && npm run dev -- --host %HOST_IP% --port 3000 --strict-port
|
||||
|
||||
REM When the frontend exits, also kill the backend server
|
||||
taskkill /f /im "node.exe" /fi "WINDOWTITLE eq npm run dev:server" 2>nul
|
||||
@@ -1,42 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Make script executable if it isn't already
|
||||
chmod +x "$0"
|
||||
|
||||
# Stop any running Pulse Docker containers first
|
||||
echo "Stopping any running Pulse Docker containers..."
|
||||
if command -v docker &> /dev/null; then
|
||||
docker ps -q --filter "name=pulse" | xargs -r docker stop
|
||||
else
|
||||
echo "Docker not found, skipping container cleanup..."
|
||||
fi
|
||||
|
||||
# Kill any existing servers
|
||||
echo "Killing any existing servers..."
|
||||
pkill -f "node dist/server.js" || true
|
||||
npx kill-port 7654 3000
|
||||
|
||||
# Set environment to development
|
||||
export NODE_ENV=development
|
||||
|
||||
# Start the real backend server
|
||||
echo "Starting real backend server..."
|
||||
npm run dev:server &
|
||||
BACKEND_PID=$!
|
||||
|
||||
# Wait a moment for the server to start
|
||||
sleep 3
|
||||
|
||||
# Get the host IP (use 0.0.0.0 in Docker, otherwise use localhost or your local IP)
|
||||
HOST_IP="0.0.0.0"
|
||||
if [[ -z "${DOCKER_CONTAINER}" ]]; then
|
||||
# Not in Docker, still use 0.0.0.0 to bind to all interfaces
|
||||
HOST_IP="0.0.0.0"
|
||||
fi
|
||||
|
||||
# Start the frontend Vite dev server
|
||||
echo "Starting Pulse interface..."
|
||||
cd frontend && npm run dev -- --host "${HOST_IP}" --port 3000 --strict-port
|
||||
|
||||
# When the frontend exits, also kill the backend server
|
||||
kill $BACKEND_PID
|
||||
@@ -1,63 +0,0 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
REM Stop any running Pulse Docker containers first
|
||||
echo Stopping any running Pulse Docker containers...
|
||||
where docker >nul 2>&1
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
for /f "tokens=*" %%i in ('docker ps -q --filter "name=pulse"') do (
|
||||
docker stop %%i
|
||||
)
|
||||
) else (
|
||||
echo Docker not found, skipping container cleanup...
|
||||
)
|
||||
|
||||
REM Kill any existing servers
|
||||
echo Killing any existing servers...
|
||||
taskkill /f /im "node.exe" /fi "WINDOWTITLE eq node dist/server.js" 2>nul
|
||||
call npx kill-port 7654 7655 3000
|
||||
|
||||
REM Set environment to development with mock data
|
||||
set NODE_ENV=development
|
||||
set USE_MOCK_DATA=true
|
||||
set MOCK_DATA_ENABLED=true
|
||||
|
||||
REM Start the mock data server
|
||||
echo Starting mock data server...
|
||||
start /b cmd /c "ts-node src/mock/run-server.ts > %TEMP%\pulse-mock-server.log 2>&1"
|
||||
|
||||
REM Wait a moment for the mock server to start
|
||||
timeout /t 2 /nobreak > nul
|
||||
|
||||
REM Start the backend server with mock data
|
||||
echo Starting backend server with mock data...
|
||||
start /b cmd /c "set USE_MOCK_DATA=true && set MOCK_DATA_ENABLED=true && npm run dev:server"
|
||||
|
||||
REM Wait a moment for the server to start
|
||||
timeout /t 3 /nobreak > nul
|
||||
|
||||
REM Set host IP to bind to all interfaces
|
||||
set HOST_IP=0.0.0.0
|
||||
|
||||
REM Verify mock data is enabled
|
||||
echo Verifying mock data is enabled...
|
||||
curl -s "http://localhost:7654/api/status" | findstr "mockDataEnabled" > nul
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo ✅ Mock data is enabled
|
||||
) else (
|
||||
echo ❌ Mock data is NOT enabled
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Pulse is now running with mock data!
|
||||
echo - Backend server: http://localhost:7654
|
||||
echo - Frontend: http://localhost:3000
|
||||
echo.
|
||||
|
||||
REM Start the frontend Vite dev server
|
||||
echo Starting Pulse interface with mock data...
|
||||
cd frontend && set USE_MOCK_DATA=true && set MOCK_DATA_ENABLED=true && npm run dev -- --host %HOST_IP% --port 3000
|
||||
|
||||
REM When the frontend exits, also kill the backend and mock server
|
||||
taskkill /f /im "node.exe" /fi "WINDOWTITLE eq npm run dev:server" 2>nul
|
||||
taskkill /f /im "node.exe" /fi "WINDOWTITLE eq ts-node src/mock/run-server.ts" 2>nul
|
||||
@@ -1,69 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Make script executable if it isn't already
|
||||
chmod +x "$0"
|
||||
|
||||
# Stop any running Pulse Docker containers first
|
||||
echo "Stopping any running Pulse Docker containers..."
|
||||
if command -v docker &> /dev/null; then
|
||||
docker ps -q --filter "name=pulse" | xargs -r docker stop
|
||||
else
|
||||
echo "Docker not found, skipping container cleanup..."
|
||||
fi
|
||||
|
||||
# Kill any existing servers
|
||||
echo "Killing any existing servers..."
|
||||
pkill -f "node dist/server.js" || true
|
||||
npx kill-port 7654 7655 3000
|
||||
|
||||
# Set environment to development with mock data
|
||||
export NODE_ENV=development
|
||||
export USE_MOCK_DATA=true
|
||||
export MOCK_DATA_ENABLED=true
|
||||
|
||||
# Start the mock data server
|
||||
echo "Starting mock data server..."
|
||||
ts-node src/mock/run-server.ts > /tmp/pulse-mock-server.log 2>&1 &
|
||||
MOCK_SERVER_PID=$!
|
||||
|
||||
# Wait a moment for the mock server to start
|
||||
sleep 2
|
||||
|
||||
# Check if the mock data server is running
|
||||
if ! ps -p $MOCK_SERVER_PID > /dev/null; then
|
||||
echo "Error: Mock data server failed to start."
|
||||
echo "Check the logs at /tmp/pulse-mock-server.log for details."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start the backend server with mock data
|
||||
echo "Starting backend server with mock data..."
|
||||
USE_MOCK_DATA=true MOCK_DATA_ENABLED=true npm run dev:server &
|
||||
BACKEND_PID=$!
|
||||
|
||||
# Wait a moment for the server to start
|
||||
sleep 3
|
||||
|
||||
# Get the host IP (use 0.0.0.0 in Docker, otherwise use localhost or your local IP)
|
||||
HOST_IP="0.0.0.0"
|
||||
if [[ -z "${DOCKER_CONTAINER}" ]]; then
|
||||
# Not in Docker, still use 0.0.0.0 to bind to all interfaces
|
||||
HOST_IP="0.0.0.0"
|
||||
fi
|
||||
|
||||
# Verify mock data is enabled
|
||||
echo "Verifying mock data is enabled..."
|
||||
curl -s "http://localhost:7654/api/status" | grep -q "mockDataEnabled" && echo "✅ Mock data is enabled" || echo "❌ Mock data is NOT enabled"
|
||||
|
||||
echo ""
|
||||
echo "Pulse is now running with mock data!"
|
||||
echo "- Backend server: http://localhost:7654"
|
||||
echo "- Frontend: http://localhost:3000"
|
||||
echo ""
|
||||
|
||||
# Start the frontend Vite dev server
|
||||
echo "Starting Pulse interface with mock data..."
|
||||
cd frontend && USE_MOCK_DATA=true MOCK_DATA_ENABLED=true npm run dev -- --host "${HOST_IP}" --port 3000
|
||||
|
||||
# When the frontend exits, also kill the backend and mock server
|
||||
kill $BACKEND_PID $MOCK_SERVER_PID
|
||||
@@ -1,45 +0,0 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM Kill any existing server processes
|
||||
taskkill /f /im "node.exe" /fi "WINDOWTITLE eq node dist/server.js" 2>nul
|
||||
taskkill /f /im "node.exe" /fi "WINDOWTITLE eq ts-node src/mock/run-server.ts" 2>nul
|
||||
call npx kill-port 7654 7655
|
||||
|
||||
REM Set environment to production
|
||||
set NODE_ENV=production
|
||||
|
||||
REM Check if .env.production exists and load it
|
||||
if exist .env.production (
|
||||
echo Loading production environment from .env.production
|
||||
for /f "tokens=*" %%a in (.env.production) do (
|
||||
set "line=%%a"
|
||||
if not "!line:~0,1!"=="#" (
|
||||
if not "!line!"=="" (
|
||||
set "%%a"
|
||||
)
|
||||
)
|
||||
)
|
||||
) else (
|
||||
echo WARNING: .env.production file not found. Using default .env file.
|
||||
)
|
||||
|
||||
REM Force mock data to be disabled for production
|
||||
set USE_MOCK_DATA=false
|
||||
set MOCK_DATA_ENABLED=false
|
||||
|
||||
REM Build the backend
|
||||
call npm run build
|
||||
|
||||
REM Build the frontend
|
||||
cd frontend
|
||||
call npm run build
|
||||
cd ..
|
||||
|
||||
REM Start the production server
|
||||
node dist/server.js
|
||||
|
||||
REM When the server exits, also kill the mock server if it's running
|
||||
if "%USE_MOCK_DATA%"=="true" (
|
||||
taskkill /f /im "node.exe" /fi "WINDOWTITLE eq ts-node src/mock/run-server.ts" 2>nul
|
||||
)
|
||||
@@ -1,49 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Make script executable if it isn't already
|
||||
chmod +x "$0"
|
||||
|
||||
# Kill any existing servers
|
||||
echo "Killing any existing servers..."
|
||||
pkill -f "node dist/server.js" || true
|
||||
pkill -f "ts-node src/mock/run-server.ts" || true
|
||||
npx kill-port 7654 7655
|
||||
|
||||
# Set environment to production and load the production environment file
|
||||
export NODE_ENV=production
|
||||
|
||||
# Check if .env.production exists and use it
|
||||
if [ -f .env.production ]; then
|
||||
echo "Loading production environment from .env.production"
|
||||
# Use a more careful approach to export environment variables
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
# Skip comments and empty lines
|
||||
if [[ ! "$line" =~ ^# && -n "$line" ]]; then
|
||||
# Export the variable
|
||||
export "$line"
|
||||
fi
|
||||
done < .env.production
|
||||
else
|
||||
echo "Warning: .env.production not found, using default .env file"
|
||||
fi
|
||||
|
||||
# Force mock data to be disabled for production
|
||||
export USE_MOCK_DATA=false
|
||||
export MOCK_DATA_ENABLED=false
|
||||
|
||||
# Build the backend
|
||||
echo "Building backend..."
|
||||
npm run build
|
||||
|
||||
# Build the frontend
|
||||
echo "Building frontend..."
|
||||
cd frontend && npm run build && cd ..
|
||||
|
||||
# Start the production server
|
||||
echo "Starting production server..."
|
||||
node dist/server.js
|
||||
|
||||
# When the server exits, also kill the mock server if it's running
|
||||
if [ -n "$MOCK_SERVER_PID" ]; then
|
||||
kill $MOCK_SERVER_PID
|
||||
fi
|
||||
Reference in New Issue
Block a user