# SAL Runner The SAL (System Abstraction Layer) Runner is an asynchronous job processing engine that executes Rhai scripts with access to system-level operations and infrastructure management capabilities. ## Features - **Asynchronous Processing**: Handles multiple jobs concurrently with configurable timeouts - **Redis Integration**: Uses Redis for job queue management and coordination - **System Operations**: Full access to SAL modules including OS, networking, containers, and cloud services - **Graceful Shutdown**: Responds to SIGINT (Ctrl+C) for clean termination - **Comprehensive Logging**: Detailed logging for monitoring and debugging ## Usage ```bash cargo run --bin runner_sal -- [OPTIONS] ``` ### Arguments - ``: Unique identifier for this runner instance (required, positional) ### Options - `-d, --db-path `: Database file path (default: `/tmp/sal.db`) - `-r, --redis-url `: Redis connection URL (default: `redis://localhost:6379`) - `-t, --timeout `: Default job timeout in seconds (default: `300`) ### Examples ```bash # Basic usage with default settings cargo run --bin runner_sal -- myrunner # Custom Redis URL and database path cargo run --bin runner_sal -- production-runner -r redis://prod-redis:6379 -d /var/lib/sal.db # Custom timeout for long-running jobs cargo run --bin runner_sal -- batch-runner -t 3600 ``` ## Available SAL Modules The SAL runner provides access to the following system modules through Rhai scripts: - **OS Operations**: File system, process management, system information - **Redis Client**: Redis database operations and caching - **PostgreSQL Client**: Database connectivity and queries - **Process Management**: System process control and monitoring - **Virtualization**: Container and VM management - **Git Operations**: Version control system integration - **Zinit Client**: Service management and initialization - **Mycelium**: Networking and mesh connectivity - **Text Processing**: String manipulation and text utilities - **Network Operations**: HTTP requests, network utilities - **Kubernetes**: Container orchestration and cluster management - **Hetzner Cloud**: Cloud infrastructure management ## Architecture The SAL runner uses an asynchronous architecture that: 1. Connects to Redis for job queue management 2. Creates a Rhai engine with all SAL modules registered 3. Processes jobs concurrently with configurable timeouts 4. Handles graceful shutdown on SIGINT 5. Provides comprehensive error handling and logging ## Error Handling The runner provides detailed error messages for common issues: - Redis connection failures - Database access problems - Script execution errors - Timeout handling - Resource cleanup on shutdown ## Logging Set the `RUST_LOG` environment variable to control logging levels: ```bash RUST_LOG=debug cargo run --bin runner_sal -- myrunner ``` Available log levels: `error`, `warn`, `info`, `debug`, `trace`