fix: remove node_modules
This commit is contained in:
51
README.md
51
README.md
@@ -51,4 +51,53 @@ spore-ui/
|
||||
- **Backend**: Express.js, Node.js
|
||||
- **Frontend**: Vanilla JavaScript, CSS3, HTML5
|
||||
- **API**: SPORE Embedded System API
|
||||
- **Design**: Glassmorphism, CSS Grid, Flexbox
|
||||
- **Design**: Glassmorphism, CSS Grid, Flexbox
|
||||
|
||||
## TODO
|
||||
|
||||
## UDP Auto Discovery
|
||||
|
||||
The backend now includes automatic UDP discovery for SPORE nodes on the network. This eliminates the need for hardcoded IP addresses.
|
||||
|
||||
### How It Works
|
||||
|
||||
1. **UDP Server**: The backend listens on port 4210 for UDP messages
|
||||
2. **Discovery Message**: Nodes send `CLUSTER_DISCOVERY` messages to broadcast address `255.255.255.255:4210`
|
||||
3. **Auto Configuration**: When a discovery message is received, the source IP is automatically used to configure the SporeApiClient
|
||||
4. **Dynamic Updates**: The system automatically switches to the most recently seen node as the primary connection
|
||||
|
||||
### Discovery Endpoints
|
||||
|
||||
- `GET /api/discovery/nodes` - View all discovered nodes and current status
|
||||
- `POST /api/discovery/refresh` - Manually trigger discovery refresh
|
||||
- `POST /api/discovery/primary/:ip` - Manually set a specific node as primary
|
||||
- `GET /api/health` - Health check including discovery status
|
||||
|
||||
### Testing Discovery
|
||||
|
||||
Use the included test script to send discovery messages:
|
||||
|
||||
```bash
|
||||
# Send to broadcast address
|
||||
npm run test-discovery broadcast
|
||||
|
||||
# Send to specific IP
|
||||
npm run test-discovery 192.168.1.100
|
||||
|
||||
# Send multiple messages
|
||||
npm run test-discovery broadcast 5
|
||||
```
|
||||
|
||||
### Node Behavior
|
||||
|
||||
- Nodes should send `CLUSTER_DISCOVERY` messages periodically (recommended: every 30-60 seconds)
|
||||
- The backend automatically cleans up stale nodes (not seen for 5+ minutes)
|
||||
- The most recently seen node becomes the primary connection
|
||||
- All API endpoints automatically use the discovered node IPs
|
||||
|
||||
### Configuration
|
||||
|
||||
- UDP Discovery Port: 4210 (configurable via `UDP_PORT` constant)
|
||||
- Discovery Message: `CLUSTER_DISCOVERY` (configurable via `DISCOVERY_MESSAGE` constant)
|
||||
- Stale Node Timeout: 5 minutes (configurable in `cleanupStaleNodes()` function)
|
||||
- Health Check Interval: 5 seconds (configurable in `setInterval`)
|
||||
Reference in New Issue
Block a user