このページはまだ翻訳されておらず、英語で表示されています。
Lifecycle
Lifecycle management controls the initialization and shutdown of Elements Hub services. Proper lifecycle management ensures devices are properly configured and resources are cleaned up correctly.
Endpoints Overview
| Method | Endpoint | Description |
|---|---|---|
| POST | /v1/lifecycle/initialize |
Initialize services |
| POST | /v1/lifecycle/shutdown |
Shutdown services |
Initialize Services
Initialize the Elements Hub services with configuration settings. This must be called before using device-related functionality.
Request
POST /v1/lifecycle/initialize
Content-Type: application/json
{
"dataDirectory": "C:\\ProgramData\\ElementsHub\\Data",
"logDirectory": "C:\\ProgramData\\ElementsHub\\Logs"
}
curl -X POST http://localhost:42042/v1/lifecycle/initialize \
-H "Content-Type: application/json" \
-d '{
"dataDirectory": "C:\\ProgramData\\ElementsHub\\Data",
"logDirectory": "C:\\ProgramData\\ElementsHub\\Logs"
}'
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
dataDirectory |
string | Yes | Path for data storage |
logDirectory |
string | Yes | Path for log files |
The response body is the string "Initialization complete." on success.
Directory Requirements
Data Directory
- Purpose: Store device configurations, calibration data, measurement results.
- Permissions: Read/write access required.
- Example:
C:\ProgramData\ElementsHub\Data
Log Directory
- Purpose: Store device operation logs.
- Permissions: Write access required.
- Example:
C:\ProgramData\ElementsHub\Logs
Shutdown Services
Gracefully shutdown all Elements Hub services, disconnect devices, and clean up resources.
Request
POST /v1/lifecycle/shutdown
curl -X POST http://localhost:42042/v1/lifecycle/shutdown
The request body is empty. The response body is the string "Service shutdown complete." on success.
Shutdown Process
- Stop Active Scans: Cancel any running device scans.
- Disconnect Devices: Safely disconnect all connected devices.
- Save State: Persist any pending data or configurations.
- Release Resources: Free system resources and handles.
- Close Logs: Flush and close log files.
Best Practices
Initialization
- Always initialize services before device operations.
- Verify directory permissions before initialization.
- Validate system health after initialization with `GET /v1/system/checks`.
Shutdown
- Implement graceful shutdown in signal handlers.
- Allow time for cleanup operations to complete.
- Handle force shutdown scenarios.
- Log shutdown events for troubleshooting.
- Ensure resources are properly released.
Directory Management
- Use absolute paths for directories.
- Ensure sufficient disk space.
- Implement directory cleanup policies.
- Monitor disk usage over time.
- Backup critical data regularly.
Error Recovery
- Implement automatic retry for initialization failures.
- Provide clear error messages to users.
- Log all lifecycle events for debugging.
- Handle partial initialization states.
- Implement health checks after operations.