[Unit]
Description=AVC optometry phone agent (Pipecat + Twilio, local GPU)
Documentation=file:///home/tocmo0nlord/avc-phone/README.md
# Needs the network up and Ollama serving the activeblue-avc model. Docker (Odoo) is
# only a soft dependency — the agent falls back to JSONL if Odoo is down — so it is
# ordered after but not required.
Wants=network-online.target
After=network-online.target ollama.service docker.service
# Restart rate limit (these are [Unit]-level directives).
StartLimitIntervalSec=300
StartLimitBurst=5

[Service]
Type=simple
User=tocmo0nlord
Group=tocmo0nlord
WorkingDirectory=/home/tocmo0nlord/avc-phone
# run.sh loads .env, sets LD_LIBRARY_PATH for the CUDA libs, and execs the server.
ExecStart=/home/tocmo0nlord/avc-phone/run.sh
# A phone line should always come back up.
Restart=always
RestartSec=5
# Keep logging to the file the tooling reads (scripts/score_calls.py, transcript
# extraction) — under systemd stdout/stderr would otherwise go only to the journal.
StandardOutput=append:/home/tocmo0nlord/avc-phone/avc_run.log
StandardError=append:/home/tocmo0nlord/avc-phone/avc_run.log
# Give model loads time before a failed start counts against the restart limit.
TimeoutStartSec=120

# Light hardening. Home is left writable on purpose: the app reads the shared venv +
# Kokoro models + HF Whisper cache under /home and writes the JSONL fallback, so a
# read-only home would risk breaking model-cache locks. /usr,/etc stay read-only.
NoNewPrivileges=true
ProtectSystem=full
PrivateTmp=true

[Install]
WantedBy=multi-user.target
