tomer doron 35ea48e628 update ci setup (#24)
motivation: 5.2 adoption, prepare for 5.3

changes:
* use 5.2 release in docker-compose setup
* add 5.3 docker-compose setup (placeholder)
* format
2020-04-03 19:51:07 -07:00
2020-04-03 19:51:07 -07:00
2020-03-31 20:22:30 -07:00
2020-03-18 11:56:30 -07:00
2020-03-18 11:56:30 -07:00
2020-04-03 19:51:07 -07:00
2020-03-18 11:56:30 -07:00
2020-03-18 11:56:30 -07:00
2020-03-31 20:08:32 -07:00
2020-03-18 11:56:30 -07:00
2020-03-31 20:08:32 -07:00
2020-03-23 11:35:55 -07:00

SwiftServiceLauncher

SwiftServiceLauncher provides a basic mechanism to cleanly start up and shut down the application, freeing resources in order before exiting. It also provides a Signal based shutdown hook, to shutdown on signals like TERM or INT.

SwiftServiceLauncher is non-framework specific, designed to be integrated with any server framework or directly in an application.

Usage

var lifecycle = Lifecycle()

let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
lifecycle.registerShutdown(
    name: "eventLoopGroup",
    eventLoopGroup.syncShutdownGracefully
)

let httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup))
lifecycle.registerShutdown(
    name: "HTTPClient",
    httpClient.syncShutdown
)

lifecycle.start() { error in
    if let error = error {
        logger.error("failed starting \(self) ☠️: \(error)")
    } else {
        logger.info("\(self) started successfully 🚀")
    }
}
lifecycle.wait()
S
Description
Mirror of github.com/swift-server/swift-service-lifecycle
Readme Apache-2.0
1.1 MiB
0 Stars 1 Watchers 0 Forks
Languages
Swift 100%