A lightweight, reusable pre-deployment safety gate runner for Python web services and background workers.
Starting a backend application or microservice in an incomplete or unconfigured state leads to silent runtime failures, half-initialized database pools, and unexpected crashes when handling customer traffic.
predeploy-runner solves this problem by acting as an automated pre-flight safety gate. It validates mandatory environment variables and performs reachability checks against critical infrastructure dependencies (such as Redis and databases) before application servers or background workers are permitted to boot.
Install the package into your project using uv:
uv add predeploy-runner 5. Configuration The pre-deployment gate can be configured via environment variables.
When PREDEPLOY_REQUIRED_VARS is not set, the runner validates the following default set:
Note: Always use real environment values or secret stores in production. Never commit credentials, passwords, or tokens to version control.
Run the pre-deployment safety gate directly from your deployment or startup script:
# Using default variables uv run pre-deploy-runner # Using a custom list of required environment variables export PREDEPLOY_REQUIRED_VARS="DATABASE_URL,REDIS_URL,PORT" uv run pre-deploy-runner When all checks pass, the process exits with 0. If any required variable is missing, it logs a descriptive fatal message and exits with 1, terminating application startup.
You can also use the package directly in your Python code.
import sys from predeploy_runner import verify_environment required_keys = ["API_KEY", "DATABASE_URL", "PORT"] is_valid, missing_keys = verify_environment(required_keys) if not is_valid: print(f"Startup aborted! Missing environment variables: {missing_keys}") sys.exit(1) print("All required environment variables are present.") Example 2: Checking TCP Service Reachability from predeploy_runner import check_tcp_service # Verify database host is reachable on port 5432 with a 3-second timeout is_reachable = check_tcp_service(host="localhost", port=5432, timeout=3.0) if not is_reachable: print("Warning: Database host is unreachable.") else: print("Database port is open and accepting connections.") Example 3: Checking URL Connectivity from predeploy_runner.runner import check_url_connectivity # Verify connection to a cache URL redis_endpoint = "redis://localhost:6379/0" is_connected = check_url_connectivity(redis_endpoint, default_port=6379, timeout=2.0) if is_connected: print("Cache endpoint is reachable.") else: print("Cache endpoint connection failed.") 7. Public API Reference verify_environment(required_vars: list[str]) -> tuple[bool, list[str]] Checks that every environment variable name provided in required_vars is defined and non-empty in the current process environment.
Performs a raw TCP connection attempt to determine if a target service port is reachable.
Parses a URL, extracts the hostname and port number, and tests TCP reachability using check_tcp_service.
The CLI entrypoint invoked by the console command pre-deploy-runner. It checks the variables specified in PREDEPLOY_REQUIRED_VARS (or defaults), probes REDIS_URL if present, and calls sys.exit(1) upon failure.
git clone cd predeploy-runner 2. Install Dependencies Install development and test dependencies using uv:
uv sync 3. Run Tests Execute the unit test suite using pytest:
uv run pytest 9. Versioning This project adheres to Semantic Versioning (SemVer):
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Nov 20, 2026 2 release files No provenance




