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

Add shutdown. #111

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add shutdown. #111

wants to merge 4 commits into from

Conversation

davidlehn
Copy link
Member

A shutdown() API is added to perform orderly shutdown. This came about due to how bedrock-test was exiting. In the flow it uses, calling bedrock.exit() or process.exit() after successful testing results in a more abrupt shutdown. There isn't a way to exit and emit orderly events on the way. In some testing cases you may want bedrock.exit or similar events to trigger to do cleanup.

This patch attempts to keep the same semantics for current code and only adds the shutdown() call (and does some refactoring). Retaining all prior behavior in all cases isn't well tested. Help wanted.

shutdown() could be named something else or be hacked into exit() as options, but this seemed like a simple approach. At the time this was written, it wasn't named stop(), but now I can't recall the reasoning and that might be a better choice as it aligns with start/stop semantics and event naming. Comments welcome.

Copy link

codecov bot commented Mar 2, 2024

Codecov Report

Merging #111 (c117058) into main (80edacd) will decrease coverage by 0.09%.
The diff coverage is 73.91%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #111      +/-   ##
==========================================
- Coverage   81.45%   81.37%   -0.09%     
==========================================
  Files          10       10              
  Lines        1941     1954      +13     
==========================================
+ Hits         1581     1590       +9     
- Misses        360      364       +4     
Files Coverage Δ
lib/index.js 69.28% <73.91%> (-0.01%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80edacd...c117058. Read the comment docs.

Copy link
Member

@dlongley dlongley left a comment

Choose a reason for hiding this comment

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

The high-level design here looks good, so assuming this works as expected, +1. Thanks!

The `shutdown()` call performs an orderly shutdown and emits events.
This differs from the current `exit()` and `process.exit()` behavior
which is more immediate.
@mattcollier
Copy link
Contributor

This does not appear to impact how Bedrock behaves when it receives a SIGTERM, is that correct?

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.

3 participants