What is the best practice to do the healthcheck en...
# ask-ai
b
What is the best practice to do the healthcheck endpoint for the worker agent?
Copy code
cli.run_app(
        WorkerOptions(
            agent_name=agent_name,
            request_fnc=request_handler,
            entrypoint_fnc=entrypoint_handler,
            # No prewarming for now to keep it lean as requested
            initialize_process_timeout=30,
            job_memory_warn_mb=4096,  # Warn at 4GB (AI models need this)
            job_memory_limit_mb=8192,  # Limit at 8GB
            num_idle_processes=num_idle_processes,
            shutdown_process_timeout=60,  # Keep processes alive for 60s
        )
    )
t
Thanks for reaching out, Jura. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm glad you're looking into the best way to implement a health check endpoint for your worker agent! A great approach is to use the built-in HTTP server that comes with the LiveKit Agents framework. This handy server automatically provides a health check endpoint right at the root (
/
) path. Here’s how it works by default: • The server listens on
http://0.0.0.0:8081/
. • The
/
endpoint will respond with
200 OK
and the simple text "OK" when your agent is healthy and running smoothly. • If a critical part of the system, like the inference executor, isn’t running, it will return
503 Service Unavailable
to let you know something needs attention. There’s also a
/worker
endpoint available that provides more detailed information about your worker, including the agent name, how many jobs are active, and the SDK version. To make sure everything works perfectly: • Remember to expose port
8081
in your deployment environment, whether that’s Docker, Kubernetes, or another platform. • Use the
/
endpoint for quick liveness checks, and the
/worker
endpoint when you want to dig into detailed state information. Generally, you won’t need to build any custom health checks unless you want to go beyond what the default monitoring offers. Sources: Deploying to custom environments | LiveKit Docs | livekit-agents/livekit/agents/worker.py | README.md | python-agent-example-app/Dockerfile