Overview
Lightd can sync container status and events to a remote management server, enabling centralized monitoring and control across multiple Lightd instances.Configuration
Enable remote sync inconfig.json:
enabled(boolean) - Enable/disable remote syncurl(string) - Remote API base URLtoken(string) - Authentication token
Remote Server Requirements
Your remote server must implement these endpoints:Health Check
Endpoint:GET /health
Headers:
Receive Updates
Endpoint:POST /update
Headers:
installing- Container is being installedready- Container installation complete and readyfailed- Container installation or operation failed
Event Flow
Container Installation
Installing notification
Lightd → Remote:
{"event": "update", "server": "id", "status": "installing"}Container Error
Container Reinstall
Installing notification
Lightd → Remote:
{"event": "update", "server": "id", "status": "installing"}Lifecycle Events Synced
| Lifecycle Event | Remote Status | Notes |
|---|---|---|
| Started | installing | Installation started |
| CreatingContainer | installing | Docker container being created |
| Ready | ready | Container ready to start |
| Error | failed | Installation failed |
| ReinstallStarted | installing | Reinstall triggered |
Health Check Loop
Lightd performs health checks every 30 seconds:Error Handling
Remote Unreachable:- Lightd logs error but continues operating
- Updates are lost (no retry queue)
- Health check continues attempting connection
- Lightd logs error
- Verify tokens match on both sides
- HTTP requests timeout after 10 seconds
- Lightd logs timeout and continues
Local API Routes
Lightd provides routes to manage remote config:Get Current Config
Reload Config
Currently reloads from file but doesn’t update running application. Restart required for changes.
Implementation Example
Here’s a complete Express.js example for a remote server:Security Considerations
Use HTTPS
Use HTTPS
Always use HTTPS for remote URL in production to encrypt data in transit.
Secure tokens
Secure tokens
Keep tokens secure and rotate regularly. Use environment variables or secrets managers.
Validate incoming data
Validate incoming data
Validate all incoming data on remote server to prevent injection attacks.
Rate limiting
Rate limiting
Implement rate limiting on remote endpoints to prevent abuse.
Audit logging
Audit logging
Log all sync attempts for audit trail and debugging.
Troubleshooting
Remote not receiving updates:- Check
remote.enabledistruein config.json - Verify remote URL is correct
- Ensure tokens match on both sides
- Check remote server logs for errors
- Verify remote
/healthendpoint returns correct response
- Verify remote server is running
- Check network connectivity
- Verify token authentication
- Check remote server logs
- Updates are sent immediately (non-blocking)
- Check network latency
- Verify remote server is processing requests quickly