Skip to content

Apex — Operations Runbook

Restart, debug, monitor, scale.

ServiceManaged byHealth check
OllamaLaunchAgent com.apex.ollamacurl http://127.0.0.1:11434/api/tags
LiteLLMLaunchAgent com.cmmd.litellm-apexcurl http://127.0.0.1:4000/health
cloudflared (apex tunnel)LaunchAgent com.cmmd.cloudflared-apexpgrep -lf cloudflared
node_exporterLaunchAgent com.prometheus.node_exportercurl http://127.0.0.1:9100/metrics
ServiceManaged byHealth check
Ollamasystemd ollama.servicesystemctl is-active ollama
LiteLLMsystemd litellm-apex.servicesystemctl is-active litellm-apex
cloudflared (lab-apex tunnel)systemd cloudflared-lab-apex.servicesystemctl is-active cloudflared-lab-apex
node_exportersystemd node_exporter.servicecurl http://127.0.0.1:9100/metrics

Sentinel:

Terminal window
ssh mac-studio 'launchctl kickstart -k gui/$(id -u)/com.cmmd.litellm-apex'

Ryzen:

Terminal window
ssh ryzen 'sudo systemctl restart litellm-apex'
Terminal window
# Sentinel
ssh mac-studio 'ollama pull <model>'
# Ryzen
ssh ryzen 'ollama pull <model>'

After pulling, add the alias to LiteLLM config and restart LiteLLM. Source of truth is cmmd-center/apex/<host>/litellm/config.yaml and cmmd-center/apex/models/registry.yml.

Re-deploy all Apex configs from source-of-truth

Section titled “Re-deploy all Apex configs from source-of-truth”
Terminal window
cd ~/projects/apex
./scripts/deploy-mac-studio.sh
./scripts/deploy-ryzen.sh

Phase C will run these automatically on merge to cmmd-center/apex main.

Terminal window
export APEX_API_KEY="$(security find-generic-password -s apex-api.cmmd.ai -a apex-core -w)"
# apex-core
curl -s -m 30 https://apex-api.cmmd.ai/v1/messages \
-H "x-api-key: $APEX_API_KEY" -H "anthropic-version: 2023-06-01" \
-d '{"model":"apex-core","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}'
# lab-flash
curl -s -m 30 https://lab-apex-api.cmmd.ai/v1/messages \
-H "x-api-key: $APEX_API_KEY" -H "anthropic-version: 2023-06-01" \
-d '{"model":"lab-flash","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}'

Live dashboard: https://monitor.aphaiboon.comServices → Apex API & Lab API — LiteLLM Monitoring.

Panels include:

  • Service up/down per tier
  • In-flight requests
  • Request rate (req/s)
  • Latency p50/p95/p99 by model
  • Proxy overhead (p95)
  • Input/output tokens by model
  • Per-output-token speed

Prometheus scrapes both LiteLLM instances every 15s at <tailnet-ip>:4000/metrics/.

Cloudflare reached the tunnel but LiteLLM not responding on :4000. Check the service:

  • Sentinel: ssh mac-studio 'launchctl list | grep litellm; tail -20 /tmp/litellm-apex.log'
  • Ryzen: ssh ryzen 'sudo journalctl -u litellm-apex --since "5 min ago" -n 30'

Wrong/missing master key. Verify via:

Terminal window
security find-generic-password -s apex-api.cmmd.ai -a apex-core -w

Compare with on-host:

Terminal window
ssh mac-studio 'cat ~/.apex/litellm/.master_key'

If they differ, the keychain version is canonical — push to host.

LiteLLM config doesn’t have that alias OR Ollama doesn’t have the model. Check both:

Terminal window
ssh mac-studio 'cat ~/.apex/litellm/config.yaml && ollama list'

Model may have been swapped out by Ollama’s KEEP_ALIVE timeout. First call after idle = model load (slow). Subsequent calls = warm.

If slowness persists with warm model, check load on the host:

Terminal window
ssh mac-studio 'top -l 1 -n 0 | grep -E "Load|PhysMem"'

Tunnel daemon stopped on host. Check:

Terminal window
ssh mac-studio 'launchctl list | grep cloudflared-apex' # should show non-zero PID
ssh ryzen 'sudo systemctl status cloudflared-lab-apex'

Restart via the LaunchAgent / systemd unit.

HostTotal RAMReserved for modelConcurrent requests @ 8K ctx
Sentinel (M1 Ultra 128 GB)128 GB81 GB (apex-core) + ~10 GB overhead6-10 native, 4 concurrent slots
Ryzen (32 GB + 8 GB GPU)32 GB~23 GB (both lab models swapping)4-6 native

For higher concurrency, add more nodes or increase OLLAMA_NUM_PARALLEL. Production scaling is Phase E (not yet planned).