docs: update

This commit is contained in:
2025-10-19 14:05:00 +02:00
parent d166b0b634
commit 56e54e0b31
3 changed files with 13 additions and 13 deletions

View File

@@ -8,12 +8,12 @@ The backend has been successfully updated to implement UDP auto discovery, elimi
### 1. UDP Discovery Server
- **Port**: 4210 (configurable via `UDP_PORT` constant)
- **Message**: `CLUSTER_DISCOVERY` (configurable via `DISCOVERY_MESSAGE` constant)
- **Message**: `CLUSTER_HEARTBEAT` (configurable via `HEARTBEAT_MESSAGE` constant)
- **Protocol**: UDP broadcast listening
- **Auto-binding**: Automatically binds to the specified port on startup
### 2. Dynamic Node Management
- **Automatic Discovery**: Nodes are discovered when they send `CLUSTER_DISCOVERY` messages
- **Automatic Discovery**: Nodes are discovered when they send `CLUSTER_HEARTBEAT` messages
- **Primary Node Selection**: The most recently seen node becomes the primary connection
- **Stale Node Cleanup**: Nodes not seen for 5+ minutes are automatically removed
- **Health Monitoring**: Continuous monitoring of node availability
@@ -45,14 +45,14 @@ The backend has been successfully updated to implement UDP auto discovery, elimi
```
1. Backend starts and binds UDP server to port 4210
2. HTTP server starts on port 3001
3. System waits for CLUSTER_DISCOVERY messages
3. System waits for CLUSTER_HEARTBEAT messages
4. When messages arrive, nodes are automatically discovered
5. SporeApiClient is configured with the first discovered node
```
### 2. Discovery Process
```
1. Node sends "CLUSTER_DISCOVERY" to 255.255.255.255:4210
1. Node sends "CLUSTER_HEARTBEAT:hostname" to 255.255.255.255:4210
2. Backend receives message and extracts source IP
3. Node is added to discovered nodes list
4. If no primary node exists, this becomes the primary
@@ -71,11 +71,11 @@ The backend has been successfully updated to implement UDP auto discovery, elimi
### Environment Variables
- `PORT`: HTTP server port (default: 3001)
- `UDP_PORT`: UDP discovery port (default: 4210)
- `UDP_PORT`: UDP heartbeat port (default: 4210)
### Constants (in index.js)
- `UDP_PORT`: Discovery port (currently 4210)
- `DISCOVERY_MESSAGE`: Expected message (currently "CLUSTER_DISCOVERY")
- `UDP_PORT`: Heartbeat port (currently 4210)
- `HEARTBEAT_MESSAGE`: Expected message (currently "CLUSTER_HEARTBEAT")
- Stale timeout: 5 minutes (configurable in `cleanupStaleNodes()`)
- Health check interval: 5 seconds (configurable in `setInterval`)