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

apollo-server-core: Improve SIGINT/SIGTERM handling #4991

Merged
merged 1 commit into from
Mar 9, 2021

Conversation

glasser
Copy link
Member

@glasser glasser commented Mar 6, 2021

Two improvements to the SIGINT and SIGTERM signal handlers that are installed by
default in non-test mode if you don't pass stopOnTerminationSignals: false.

  • If another SIGINT or SIGTERM is received while awaiting stop(), ignore
    it (ie, prevent the process from exiting if this was the only handler for that
    signal). This is implemented by switching the process.once to process.on
    and explicitly tracking if a signal has been received. Fixes SIGINT/SIGTERM handling doesn't wait for promises #4931.

  • If await this.stop() throws, make sure to shut down the process anyway after
    logging. This does process.exit(1) instead of re-signaling because it can't
    be sure that the signal handler has been removed.

Two improvements to the SIGINT and SIGTERM signal handlers that are installed by
default in non-test mode if you don't pass `stopOnTerminationSignals: false`.

- If another SIGINT or SIGTERM is recieved while awaiting `stop()`, ignore
  it (ie, prevent the process from exiting if this was the only handler for that
  signal). This is implemented by switching the `process.once` to `process.on`
  and explicitly tracking if a signal has been received. Fixes #4931.

- If `await this.stop()` throws, make sure to shut down the process anyway after
  logging. This does `process.exit(1)` instead of re-signaling because it can't
  be sure that the signal handler has been removed.
@glasser glasser force-pushed the glasser/improve-signal-handling branch from de19e31 to eb9b5f2 Compare March 9, 2021 21:18
@glasser glasser enabled auto-merge (squash) March 9, 2021 21:19
@glasser glasser merged commit 97185de into main Mar 9, 2021
@glasser glasser deleted the glasser/improve-signal-handling branch March 9, 2021 21:22
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SIGINT/SIGTERM handling doesn't wait for promises
2 participants