Improve shutdown behaviour
Closed this issue · 2 comments
Description
Determine the best mechanism to wait until a service is shutting down and provide a hook to easily shutdown clients etc that where initialised at the start of the application.
Currently we are waiting on the current runloop which may not be the best mechanism to wait until a service is shutting down and providing an opportunity to close clients. It looks like Kitura uses a DispatchGroup[2] to wait until the server is shutting down.
Exit criteria
- Investigate the best mechanism for waiting for service shutdown and providing an opportunity for applications to shut down clients etc
- Provide implementation for this new shutdown behaviour
- Update documentation to include this behaviour
[1] https://github.com/amzn/smoke-framework/blob/master/Sources/SmokeOperationsHTTP1/SmokeHTTP1Server%2BstartAsOperationServer.swift#L54
[2] https://github.com/IBM-Swift/Kitura-NIO/blob/5d9bd67596881876d8a0843b41b3bff00e5c9059/Sources/KituraNet/ListenerGroup.swift
As suggested by @weissi-
https://github.com/apple/swift-nio-extras/blob/master/Sources/HTTPServerWithQuiescingDemo/main.swift
Looks like this will achieve exactly what we need.
Released in 0.9.0.