Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

42 строки
1.1 KiB

  1. @preconcurrency import Vapor
  2. import Dispatch
  3. import Logging
  4. private struct UncheckedApplication: @unchecked Sendable {
  5. let app: Application
  6. }
  7. /// This extension is temporary and can be removed once Vapor gets this support.
  8. private extension Vapor.Application {
  9. static let baseExecutionQueue = DispatchQueue(label: "vapor.codes.entrypoint")
  10. func runFromAsyncMainEntrypoint() async throws {
  11. try await withCheckedThrowingContinuation { continuation in
  12. Vapor.Application.baseExecutionQueue.async { [self] in
  13. do {
  14. try self.run()
  15. continuation.resume()
  16. } catch {
  17. continuation.resume(throwing: error)
  18. }
  19. }
  20. }
  21. }
  22. }
  23. @main
  24. enum Entrypoint {
  25. static func main() async throws {
  26. var env = try Environment.detect()
  27. try LoggingSystem.bootstrap(from: &env)
  28. let app = Application(env)
  29. defer { app.shutdown() }
  30. try await configure(app)
  31. try await app.runFromAsyncMainEntrypoint()
  32. }
  33. }