Graceful Shutdown for Cloud-Native Environments#27
Graceful Shutdown for Cloud-Native Environments#27gabriel-indik merged 2 commits intohyperledger:mainfrom
Conversation
Signed-off-by: hfuss <haydenfuss@gmail.com>
|
Once Data Exchange is started it will be listening on the API and P2P ports. I wonder if it might be worth adding a mechanism or API to stop the servers instead, bringing the execution of the application to an end. |
Signed-off-by: hfuss <haydenfuss@gmail.com>
|
Thanks for the feedback @gabriel-indik, I added some additional logic to ensure the API, P2P, and WS servers are all stopped before exiting: |
|
Changes look great. Is the process.exit() still required? I thought that once the servers are stopped the process would exit by itself, unless there is something else hanging like a file change listener. |
|
Testing locally confirms you're right that the |
While running DX on K8s as part of https://github.com/hyperledger-labs/firefly/pull/114 I noticed pods would take the entire grace period before properly shutting down. Handling
INTandQUITwill make it so we properly shut down when K8s terminates a pod (rather than using a CLI tool likedumb-init):Output from testing:
First terminal where I ran DX
And terminal where I killed DX:
Will defer to @gabriel-indik @peterbroadhurst if any additional shutdown logic should be added to
stopi.e. wait for all in-flight HTTP requests to finish, writing to disk operations, etc.