Paul Krill
Editor at Large

New Swift project handles server app startup, shutdown

news
Jul 20, 20202 mins

Swift Service Lifecycle is an open source project aimed at supporting the language’s server ecosystem

servers / server racks [close-up perspective shot]
Credit: Monsitj / Getty Images

The developers behind Apple’s Swift language have introduced an open source project for the Swift server ecosystem, called Swift Service Lifecycle, to aid server applications with managing startup and shutdown sequences.

Accessible from GitHub, Swift Service Lifecycle is a Swift package that cleanly starts up and shuts down an application, freeing resources before exiting. Also provided is a Signal-based shutdown hook to shut down on signals TERM or INT.

Swift Service Lifecycle was designed with the notion that each application has startup and workflow-like logic that often is sensitive to failure and difficult to do correctly. Startup sequences include actions like initializing thread pools, warming up caches, running data migrations, and performing other types of state initialization prior to accepting events or taking traffic. Shutdown sequences free up resources that hold on to file descriptors or other resources that could leak if not correctly cleared.

Swift Service Lifecycle codes this common need for startup and shutdown logic in a safe, reusable way that is non-framework-specific. The recommended way to use the library is to create a ServiceLifecycle instance in an application’s main method and register LifecycleTasks. When calling the start function, ServiceLifecycle will start these tasks in the order registered. ServiceLifecycle also registers a signal handler that traps TERM or INT

Swift’s potential on the server has grabbed the attention of companies such as IBM. Swift was founded in 2014 as the successor to Apple’s Objective-C language for developing on Apple platforms such as MacOS and iOS.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author