A powerful Node.js application for automatically downloading and managing weather data files from OpenMeteo's spatial data API. This orchestrator supports multiple weather models, priority-based downloads, automatic cleanup, and comprehensive testing.
- Multi-Model Support: Download data from 50+ weather models (DWD, ECMWF, MeteoFrance, NCEP, etc.)
- Automatic Scheduling: Cron-based scheduling for regular data checks and downloads
- Priority Downloads: Queue-based system with priority levels for urgent downloads
- Automatic Cleanup: Configurable retention periods with automatic file cleanup
- Fake Mode: Simulation mode for testing without actual downloads
- Local Caching: LMDB-based caching for fast file path resolution
- Comprehensive Logging: Detailed logging with Winston for monitoring and debugging
- Permission Testing: Pre-deployment permission validation
- Queue Management: Separate queues for downloads and cleanup operations
- Error Handling: Robust error handling with retry logic
- Statistics Tracking: Real-time statistics for monitoring performance
- Graceful Shutdown: Clean shutdown with queue completion
The orchestrator supports 50+ weather models including:
- DWD Models: ICON, ICON D2, ICON EU, ICON EPS, EWAM, GWAM
- ECMWF Models: IFS025, AIFS025, WAM025 (single and ensemble)
- MeteoFrance Models: AROME France, ARPEGE Europe/World, Currents, Wave
- NCEP Models: GFS, GEFS, HRRR, NAM, NBM
- Regional Models: MeteoSwiss ICON, KNMI HARMONIE, DMI HARMONIE
- Air Quality: CAMS Europe/Global, CAMS Greenhouse Gases
- And many more...
- Node.js 16+
- npm or yarn
# Install from npm
npm install om-file-orchestrator
# Or install from GitHub
npm install github:Sebswan/om-file-orchestrator# Clone the repository
git clone <repository-url>
cd om-file-orchestrator
# Install dependencies
npm install
# Run setup script
npm run setup
# Test permissions
npm run test:quick{
"queue": {
"concurrency": 1,
"interval": 1000,
"intervalCap": 10,
"timeout": 60000,
"retries": 3
},
"storage": {
"cacheDir": "./cache",
"maxFileSize": 30971520
},
"logging": {
"level": "info",
"file": "./logs/orchestrator.log"
},
"lmdb": {
"path": "./cache/lmdb",
"mapSize": 104857600
}
}Each model can be configured with:
enabled: Enable/disable the modelmanaged:falsefor a model fed by an external process β its files are still indexed and cleaned up, but never downloaded (baseUrl/statusFileunused). Defaults totrue.retentionHours: retention period in hours. Files are dropped on their mtime (when they were downloaded or written), LMDB keys on the forecast step they name. A model without this field is never cleaned up. Honoured since 2.0.0 β earlier versions ignored it and always applied 24 h.checkInterval: Cron expression for checking frequencybaseUrl: Base URL for the model's datastatusFile: Path to the in-progress status file
const { createOrchestratorWithDefaults } = require('om-file-orchestrator');
// Create orchestrator with defaults
const orchestrator = createOrchestratorWithDefaults({
cacheDir: './weather-cache',
concurrency: 2,
logLevel: 'info',
fakeMode: false
});
// Start orchestrator
await orchestrator.start();
// Download file with priority
await orchestrator.downloadWithPriority(
'dwd_icon_d2/2025/09/11/0600Z/2025-09-11T0600.om',
1 // High priority
);
// Get statistics
const stats = orchestrator.getStats();
// Stop orchestrator
await orchestrator.stop();# Start the orchestrator
npm start
# Start with immediate check
npm run dev
# Start in fake mode (no real downloads)
npm run start:fake# Run examples
npm run example:simple # Basic usage example
npm run example:fastify # Fastify integration example
npm run example:custom # Custom configuration example// Download with high priority
await orchestrator.downloadWithPriority(
'dwd_icon_d2/2025/09/11/0600Z/2025-09-11T0600.om',
1 // Priority level (0=normal, 1=high, 2=max)
);// Manual cleanup
await orchestrator.cleanupNow();
// Manual check for specific model
await orchestrator.checkNow('dwd_icon_d2');
// Get statistics
const stats = orchestrator.getStats();# Run all tests
npm test
# Quick permission test
npm run test:quick
# Test priority system
npm run test:priority
# Test specific scenarios
# Test specific scenarios
npm run test:permissions
# Verify LMDB logic
node test/verify-lmdb-crud.js # Test Set/Get/Cleanup
node test/verify-lmdb-rebuild.js # Test Index Rebuild- Permission Tests: Validates write/read/delete permissions
- File Operations: Tests file creation, reading, and deletion
- Concurrent Operations: Tests simultaneous file operations
- Large File Handling: Tests with large files (1MB+)
- Priority System: Tests download priority ordering
- Subdirectory Creation: Tests nested directory structure
The orchestrator provides real-time statistics:
π Statistics:
Files checked: 49
Files downloaded: 12
Files skipped: 37
Files deleted: 8
Errors: 0
Cleanup errors: 0
Download queue: 0 (0 pending)
Cleanup queue: 0 (0 pending)
Last check: Thu Sep 11 2025 12:30:00 GMT+0200
Last cleanup: Thu Sep 11 2025 12:00:00 GMT+0200
- Console Output: Real-time status updates
- File Logging: Detailed logs saved to
./logs/orchestrator.log - Log Levels: debug, info, warn, error
- Log Rotation: Automatic log rotation (5MB max, 5 files)
{
"queue": {
"concurrency": 2, // Parallel downloads
"interval": 1000, // Interval between downloads (ms)
"intervalCap": 10, // Max downloads per interval
"timeout": 60000, // Download timeout (ms)
"retries": 3 // Retry attempts
}
}- Automatic Cleanup: Runs every hour via cron
- Retention Periods: Configurable per model (3h to 24h+)
- Cleanup Queue: Separate queue for file deletions
- Empty Directory Removal: Automatically removes empty directories
- Priority Levels: 0 (normal), 1 (high), 2 (maximum)
- Queue Ordering: Higher priority downloads processed first
- Priority Logging: Clear indication of priority downloads
- Embedded Database: Uses LMDB for high-performance, serverless caching
- Path Resolution: Stores mappings between timestamps and file paths
- Persistence: Rebuilds index from disk on startup to ensure consistency across deployments
- Memory Efficient: Separate databases per model
- Automatic Cleanup: Removes expired keys synchronously with file cleanup
# Test permissions
npm run test:quick
# Fix permissions
chmod 755 cache/
sudo chown -R $USER:$USER cache/- Check internet connectivity
- Verify model URLs are accessible
- Review timeout settings in config
# Check disk space
df -h
# Clean cache if needed
rm -rf cache/*Enable debug logging by setting log level to "debug" in config.json:
{
"logging": {
"level": "debug"
}
}om-file-orchestrator/
βββ cache/ # Downloaded files
βββ logs/ # Log files
βββ test/ # Test suite
β βββ test-permissions.js # Permission tests
β βββ test-scenarios.js # Comprehensive tests
β βββ test-priority.js # Priority system tests
β βββ README.md # Test documentation
βββ config.json # Main configuration
βββ config_model.json # Model configurations
βββ WeatherOrchestratorSimple.js # Main orchestrator class
βββ index.js # Application entry point
βββ package.json # Dependencies and scripts
βββ README.md # This file
new WeatherOrchestratorSimple(config, modelConfig, fakeMode)start(): Start the orchestratorstop(): Stop the orchestrator gracefullycheckNow(modelKey): Manual check for specific modelcleanupNow(): Manual cleanup triggerdownloadWithPriority(filePath, priority): Download with prioritygetStats(): Get current statisticsgetQueueInfo(): Get queue information
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the ISC License.
For issues and questions:
- Check the troubleshooting section
- Review the test suite for examples
- Enable debug logging for detailed information
- Create an issue with logs and configuration details
- Web dashboard for monitoring
- REST API for remote control
- Database integration for metadata
- Docker containerization
- Kubernetes deployment support
- Advanced scheduling options
- Data validation and integrity checks