3.4 KiB
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)
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:
- Kills any existing servers running on the required ports
- Starts the mock data server
- Starts the backend server with mock data enabled
- 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
npm run dev
This will:
- Start the mock data server
- Start the backend server with mock data enabled
- Start the frontend with mock data enabled
What's Happening Behind the Scenes
The mock data setup:
-
Sets the necessary environment variables:
NODE_ENV=developmentUSE_MOCK_DATA=trueMOCK_DATA_ENABLED=true
-
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
-
Starts the backend server with mock data enabled
- The backend connects to the mock data server instead of real Proxmox servers
- It uses the
MockClientclass to handle communication with the mock server
-
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:
-
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
-
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
-
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:
-
Edit the
src/mock/templates.tsfile- Modify the VM and container templates to add or change the available names and OS types
-
Edit the
src/mock/server.tsfile- Modify the data generation functions to create the data you need
-
Restart the mock server
Troubleshooting
If you encounter issues:
-
Check the mock server logs:
/tmp/pulse-mock-server.log -
Make sure all required ports are available:
- 7654 (backend server)
- 7655 (mock data server)
- 3000 (frontend)
-
If needed, kill existing processes:
npm run dev:kill:all -
If you get a "ts-node: command not found" error:
npm install -g ts-node -
If you encounter TypeScript errors in the mock server:
- Make sure all variables have proper type definitions
- Check the
src/mock/server.tsfile for any type errors - Run
tsc --noEmit src/mock/server.tsto check for type errors without compiling
Switching Back to Real Data
To switch back to using real Proxmox servers:
- Configure your
.envfile with real Proxmox server details - Start the application normally:
npm run dev:start