Hey Guys, How to add graceful shutdown for agent ...
# agents
e
Hey Guys, How to add graceful shutdown for agent worker? My calls are getting disconnected after doing ctrl + c. I want to wait for my all calls to get drained before my application exits
Copy code
if __name__ == "__main__":

    worker = WorkerOptions(
            entrypoint_fnc=entrypoint,
            prewarm_fnc=prewarm,
            worker_type=WorkerType.ROOM,
            shutdown_process_timeout=60,
            job_memory_warn_mb=5000,
            drain_timeout=1800,
            initialize_process_timeout=float(os.getenv("WORKER_INIT_TIME") or "30.0"),
        )
    # Run worker in main thread (required for signal handling)
    cli.run_app(worker)
r
Are you running with
start
?
e
Not exactly, using
livekit.agentscli.run_app
as given in example code.
r
Can you point me to the "example code" you mention. I want to make sure we are on the same page.
I would expect you to run the app something like this
uv run agent.py start
or
python agent.py start
https://docs.livekit.io/agents/start/voice-ai/#connect-to-playground
e
Yes, You are right we are using
python src/worker.py start
to run the agent.
@refined-appointment-81829 any suggestions here?