the ctx shutdown callback is running as expected, ...
# ask-ai
n
the ctx shutdown callback is running as expected, but the worker stays awake for another 5minutes until receiving process did not exit in time, killing process
t
Thanks for reaching out, Catalisan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! The behavior you're seeing is tied to how LiveKit Agents handle shutdown timeouts. By default, the system waits 60 seconds before forcefully stopping the process, but since your worker sticks around for 5 minutes, it probably means one of these is happening: • You’ve set a custom
shutdown_process_timeout
of 300 seconds. • Your shutdown callback is taking a bit longer than expected to finish up. • There are extra timeout settings in your deployment environment affecting this. Here’s how you can tackle this: 1. Speed Up Your Shutdown Callback: Try to keep it quick! Avoid heavy tasks like uploading big files or crunching lots of data during shutdown. 2. Adjust the Timeout: If you need more time, you can increase the timeout using the
shutdown_process_timeout
parameter in
WorkerOptions
. For example:
Copy code
from livekit.agents import WorkerOptions

# Increase shutdown timeout to 10 minutes (600 seconds)
worker_options = WorkerOptions(
    entrypoint_fnc=your_entrypoint,
    shutdown_process_timeout=600
)
1. Double-Check Your Deployment Settings: Make sure your deployment platform’s grace period (like
terminationGracePeriodSeconds
in Kubernetes) matches up well with your
shutdown_process_timeout
setting. For some extra help troubleshooting, try adding logging to your shutdown callback to see where the time’s going, confirm your
WorkerOptions
setup, and take a look at your deployment configs for any other timeout rules.