Skip to content

feat: implement graceful draining and outbound call control for SIP#600

Closed
biswajitpain wants to merge 1 commit intolivekit:mainfrom
Bigly-Sales:biglysales-v1
Closed

feat: implement graceful draining and outbound call control for SIP#600
biswajitpain wants to merge 1 commit intolivekit:mainfrom
Bigly-Sales:biglysales-v1

Conversation

@biswajitpain
Copy link

Introduce a graceful shutdown mechanism for the SIP service.

  • Add StartDrain methods to sip.Client, sip.Server, and sip.Service. These methods stop accepting new inbound SIP INVITEs and new outbound CreateSIPParticipant requests, respectively, while allowing existing calls to complete.
  • Integrate the StartDrain call into the service shutdown sequence in service.Run() to immediately prevent new call establishments.
  • Add a DisableOutboundCalls configuration option to prevent new outbound SIP calls. When enabled, CreateSIPParticipant requests will be rejected, and affinity will be zeroed out.
  • Enhance the health check endpoint:
  • Expose /healthz in addition to /.
  • Implement a 30-second grace period after service stop before exiting, allowing load balancers to detect unhealthy status.
  • Update .gitignore to include .claude.

Changes:

  • .gitignore (2 lines, 7 characters)
  • cmd/livekit-sip/main.go (2 lines, 219 characters)
  • pkg/config/config.go (4 lines, 274 characters)
  • pkg/service/service.go (26 lines, 1142 characters)
  • pkg/sip/client.go (6 lines, 213 characters)
  • pkg/sip/inbound.go (7 lines, 429 characters)
  • pkg/sip/server.go (6 lines, 220 characters)
  • pkg/sip/service.go (14 lines, 522 characters)
  • test/cloud/service.go (2 lines, 263 characters)

Introduce a graceful shutdown mechanism for the SIP service.
- Add `StartDrain` methods to `sip.Client`, `sip.Server`, and `sip.Service`. These methods stop accepting new inbound SIP INVITEs and new outbound `CreateSIPParticipant` requests, respectively, while allowing existing calls to complete.
- Integrate the `StartDrain` call into the service shutdown sequence in `service.Run()` to immediately prevent new call establishments.
- Add a `DisableOutboundCalls` configuration option to prevent new outbound SIP calls. When enabled, `CreateSIPParticipant` requests will be rejected, and affinity will be zeroed out.
- Enhance the health check endpoint:
- Expose `/healthz` in addition to `/`.
- Implement a 30-second grace period after service stop before exiting, allowing load balancers to detect unhealthy status.
- Update `.gitignore` to include `.claude`.

Changes:
- .gitignore (2 lines, 7 characters)
- cmd/livekit-sip/main.go (2 lines, 219 characters)
- pkg/config/config.go (4 lines, 274 characters)
- pkg/service/service.go (26 lines, 1142 characters)
- pkg/sip/client.go (6 lines, 213 characters)
- pkg/sip/inbound.go (7 lines, 429 characters)
- pkg/sip/server.go (6 lines, 220 characters)
- pkg/sip/service.go (14 lines, 522 characters)
- test/cloud/service.go (2 lines, 263 characters)
@biswajitpain biswajitpain requested a review from a team as a code owner February 26, 2026 06:39
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Biswajit Pain seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants