You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1003 B
Swift
36 lines
1003 B
Swift
import Vapor
|
|
import Dispatch
|
|
import Logging
|
|
|
|
/// This extension is temporary and can be removed once Vapor gets this support.
|
|
private extension Vapor.Application {
|
|
static let baseExecutionQueue = DispatchQueue(label: "vapor.codes.entrypoint")
|
|
|
|
func runFromAsyncMainEntrypoint() async throws {
|
|
try await withCheckedThrowingContinuation { continuation in
|
|
Vapor.Application.baseExecutionQueue.async { [self] in
|
|
do {
|
|
try self.run()
|
|
continuation.resume()
|
|
} catch {
|
|
continuation.resume(throwing: error)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@main
|
|
enum Entrypoint {
|
|
static func main() async throws {
|
|
var env = try Environment.detect()
|
|
try LoggingSystem.bootstrap(from: &env)
|
|
|
|
let app = Application(env)
|
|
defer { app.shutdown() }
|
|
|
|
try await configure(app)
|
|
try await app.runFromAsyncMainEntrypoint()
|
|
}
|
|
}
|