Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve shutdown Delay default #785

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions baseplate/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,14 @@ def load_app_and_run_server() -> None:
SERVER_STATE.state = ServerLifecycle.SHUTTING_DOWN

cfg = parse_config(config.server, {"drain_time": OptionalConfig(Timespan)})
# Default drain time across all baseplate language implementations
# which allows enough time for systems such as k8s to remove the
# server from the endpoints list.
drain_time_seconds = 5
if cfg.drain_time:
logger.debug("Draining inbound requests...")
time.sleep(cfg.drain_time.total_seconds())
drain_time_seconds = cfg.drain_time.total_seconds()
logger.debug("Draining inbound requests...")
time.sleep(drain_time_seconds)
finally:
logger.debug("Gracefully shutting down...")
server.stop()
Expand Down