The deriver script does "from src import crud" at the top, which only works when the cwd / sys.path[0] is /app. Running the script by file path (python /app/src/deriver/deriver.py) puts /app/src/deriver on sys.path instead, and the import fails with ModuleNotFoundError. Switch to python -m src.deriver.deriver and explicitly set WorkingDir=/app so module resolution is deterministic across Podman versions. Discovered during the first deploy of the honcho role on lincoln — honcho-api was healthy on :8000 but the deriver crash-looped 26 times in two minutes.
60 lines
2.4 KiB
Django/Jinja
60 lines
2.4 KiB
Django/Jinja
# {{ ansible_managed }}
|
|
# mk-labs Honcho deriver worker (background queue consumer)
|
|
# Managed by Ansible - honcho role
|
|
#
|
|
# Same image as the API; different command. The deriver pulls jobs off
|
|
# the DB-backed queue and calls the LLM provider to perform theory-of-mind
|
|
# derivations against user sessions.
|
|
|
|
[Unit]
|
|
Description=Honcho deriver worker
|
|
After=network-online.target {{ honcho_postgres_container_name }}.service {{ honcho_container_name }}.service
|
|
Wants=network-online.target
|
|
Requires={{ honcho_postgres_container_name }}.service
|
|
|
|
[Container]
|
|
Image={{ honcho_image }}
|
|
ContainerName={{ honcho_deriver_container_name }}
|
|
Network={{ honcho_network_name }}
|
|
|
|
# Run the deriver script instead of the FastAPI server. The deriver
|
|
# polls the queue and processes work in a loop. Number of concurrent
|
|
# workers controlled via DERIVER_WORKERS.
|
|
WorkingDir=/app
|
|
Exec=/app/.venv/bin/python -m src.deriver.deriver
|
|
|
|
# -- Database ---------------------------------------------------------------
|
|
Environment=DB_CONNECTION_URI=postgresql+psycopg://{{ honcho_db_user }}:{{ honcho_db_password }}@{{ honcho_postgres_container_name }}:5432/{{ honcho_db_name }}
|
|
|
|
# -- Auth -------------------------------------------------------------------
|
|
# Deriver does not serve HTTP, but it reads the same config object — keep
|
|
# secrets aligned with the API container.
|
|
Environment=AUTH_USE_AUTH={{ honcho_auth_enabled | string | lower }}
|
|
Environment=AUTH_JWT_SECRET={{ honcho_jwt_secret }}
|
|
|
|
# -- LLM provider -----------------------------------------------------------
|
|
{% if honcho_llm_transport == 'anthropic' %}
|
|
Environment=LLM_ANTHROPIC_API_KEY={{ honcho_anthropic_api_key }}
|
|
{% endif %}
|
|
Environment=DERIVER_ENABLED={{ honcho_deriver_enabled | string | lower }}
|
|
Environment=DERIVER_WORKERS={{ honcho_deriver_workers }}
|
|
Environment=DERIVER_POLLING_SLEEP_INTERVAL_SECONDS={{ honcho_deriver_polling_seconds }}
|
|
Environment=DERIVER_MODEL_CONFIG__TRANSPORT={{ honcho_llm_transport }}
|
|
Environment=DERIVER_MODEL_CONFIG__MODEL={{ honcho_deriver_model }}
|
|
Environment=SUMMARY_MODEL_CONFIG__TRANSPORT={{ honcho_llm_transport }}
|
|
Environment=SUMMARY_MODEL_CONFIG__MODEL={{ honcho_summary_model }}
|
|
|
|
# -- Vector store -----------------------------------------------------------
|
|
Environment=VECTOR_STORE_TYPE=pgvector
|
|
|
|
# Timezone matches host baseline
|
|
Environment=TZ=America/Chicago
|
|
Environment=LOG_LEVEL=INFO
|
|
|
|
[Service]
|
|
Restart=always
|
|
TimeoutStartSec=180
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target default.target
|