how to control the job process time such that it t...
# ask-ai
a
how to control the job process time such that it takes only mentioned time to shut down
✅ 1
t
Thanks for reaching out, Harshita. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding about controlling a job process so it shuts down within a specified time. If you’re using LiveKit’s AgentServer, set the
drain_timeout
to the maximum time you want the server to wait for active jobs during shutdown. Key points: •
drain_timeout
is the maximum wait (default 1800 seconds / 30 minutes). • Configure it when constructing the server, e.g.:
Copy code
server = AgentServer(
    drain_timeout=600,  # 10 minutes
)
• On shutdown the server stops accepting new jobs and waits up to
drain_timeout
for active jobs to finish; if jobs exceed that time an
asyncio.TimeoutError
occurs and the process exits. • In LiveKit Cloud, the effective drain window may be limited by Cloud policies (instances can get up to 1 hour during rolling deployments), so the actual shutdown window is the minimum of your
drain_timeout
and the Cloud policy. If you’re not using AgentServer, or you want the process to stop exactly at a fixed time (not just a maximum wait), tell me what runtime or job system you’re using and whether jobs can be checkpointed or cancelled — I’ll give precise steps. Sources: Server options | LiveKit Documentation | Deployment reliability on LiveKit Cloud | LiveKit, with interactive elements
a
proc shut down
t
Thanks — you're asking about forcing a process to shut down within a specific time. If you mean LiveKit’s AgentServer: set the
drain_timeout
to the maximum seconds you want the server to wait for active jobs during shutdown (example:
drain_timeout=600
for 10 minutes). The server will stop accepting new jobs, wait up to that timeout for active jobs to finish, and then exit (jobs still running will be terminated and an
asyncio.TimeoutError
will occur). Note Cloud deployments may impose their own maximum (up to 1 hour), so the effective window is the minimum of your
drain_timeout
and the Cloud policy. If you mean a different process or need the shutdown to occur exactly at a fixed time (not just a maximum wait), please tell me: • which runtime or job system you’re using (AgentServer, systemd, Kubernetes, plain Python process, etc.), and • whether jobs can be cancelled, checkpointed, or must finish gracefully. I’ll give specific steps once you confirm. , with interactive elements