Implementation:ARCANGEL0 EVA ensure local searxng running
| Knowledge Sources | |
|---|---|
| Domains | Containers, Infrastructure |
| Last Updated | 2026-10-29 14:00 GMT |
Overview
Concrete tool for ensuring a previously-configured SearXNG container is running after a host reboot, with automatic start and readiness probing, provided by the Mitsu SearXNG service module.
Description
The ensure_local_searxng_running function checks if a managed local SearXNG container is running:
- Skip if not managed: If `settings["managed_local"]` is not True, returns immediately.
- Validate settings: Checks that the saved runtime and container_name are present and valid.
- Check Docker availability: Verifies the Docker binary is still on PATH.
4 Check container state: Uses `docker container inspect` to determine if the container is running, stopped, or missing. 5 Start if stopped: Runs `docker start <container_name>` if the container is stopped. 6 Probe readiness: Polls the JSON API endpoint for up to 45 seconds (1.5s intervals).
Usage
- Before web search: Called by `_search_one` in the search engine module before querying SearXNG to ensure it's running.
- Session startup: Called when a session starts and SearXNG is configured.
Code Reference
Source Location
- Repository: Mitsu
- File: services/searxng.py
Signature
def ensure_local_searxng_running(settings: dict[str, object]) -> None: ...
Import
from mitsu.services.searxng import ensure_local_searxng_running
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| settings | dict[str, object] | Yes | Saved SearXNG config with managed_local, container_runtime, container_name, base_url |
Outputs
| Name | Type | Description |
|---|---|---|
| returns | None | Raises SearXNGSetupError if the container cannot be started or probed |
Usage Examples
Ensure SearXNG is Running
from mitsu.services.searxng import ensure_local_searxng_running
settings = {
"managed_local": True,
"container_runtime": "docker",
"container_name": "mitsu-searxng-8888",
"base_url": "http://127.0.0.1:8888",
}
try:
ensure_local_searxng_running(settings)
print("SearXNG is ready.")
except SearXNGSetupError as error:
print(f"SearXNG setup error: {error}")