Skip to content

Conversation

@kumarrah2002
Copy link
Contributor

What does this PR do?

As a user, I want the ability to shutdown a LitServe server programmatically instead of force quitting. This pull request adds a POST endpoint to the Uvicorn server (labeled /shutdown) which terminates the server using FastAPI's built-in .should_exit() function. A unit test has also been added, which has passed.

Screenshot 2025-05-22 at 4 49 39 PM

Fixes Issue #505.

Before submitting
  • [✅] Was this discussed/agreed via a Github issue? (no need for typos and docs improvements)
  • [✅] Did you read the contributor guideline, Pull Request section?
  • [✅] Did you make sure to update the docs?
  • [✅] Did you write any new necessary tests?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in GitHub issues there's a high chance it will not be merged.

Did you have fun?

This was a good challenge for me! I initially had some issues since exceptions were still arising when stopping the server, but I was able to find a way so there were no exceptions.

@codecov
Copy link

codecov bot commented May 22, 2025

Codecov Report

Attention: Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 86%. Comparing base (b7c4d58) to head (d296be4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@         Coverage Diff         @@
##           main   #507   +/-   ##
===================================
  Coverage    86%    86%           
===================================
  Files        37     37           
  Lines      2359   2373   +14     
===================================
+ Hits       2033   2046   +13     
- Misses      326    327    +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@aniketmaurya aniketmaurya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kumarrah2002!! looks good so far. added a small comment. also can you paste the whole terminal trace after shutdown please? we would want to make sure that it also terminates all the inference processes.

@kumarrah2002
Copy link
Contributor Author

kumarrah2002 commented May 23, 2025

Hi @aniketmaurya, is this a good terminal trace? Let me know if you'd like anything else added. I've also added a second POST request in the test with a 400 error code.
Screenshot 2025-05-23 at 11 26 08 AM

Copy link
Collaborator

@aniketmaurya aniketmaurya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love this! thanks for the contribution @kumarrah2002

@aniketmaurya aniketmaurya merged commit 7fcbdfb into Lightning-AI:main May 23, 2025
21 checks passed
@aniketmaurya aniketmaurya linked an issue May 23, 2025 that may be closed by this pull request
aniketmaurya added a commit that referenced this pull request May 23, 2025
Borda pushed a commit that referenced this pull request May 23, 2025
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