Skip to content

Commit

Permalink
remove main folder
Browse files Browse the repository at this point in the history
Remove old style
  • Loading branch information
saroar committed Nov 2, 2023
1 parent d91d0c2 commit e5dacbd
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ RUN swift build -c release --static-swift-stdlib \
WORKDIR /staging

# Copy main executable to staging area
RUN cp "$(swift build --package-path /build -c release --show-bin-path)/Main" ./
RUN cp "$(swift build --package-path /build -c release --show-bin-path)/App" ./

# Copy resources bundled by SPM to staging area
RUN find -L "$(swift build --package-path /build -c release --show-bin-path)/" -regex '.*\.resources$' -exec cp -Ra {} ./ \;
Expand Down
7 changes: 1 addition & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let package = Package(
.package(url: "https://github.com/vapor-community/mailgun.git", from: "5.0.0"),
],
targets: [
.target(
.executableTarget(
name: "App",
dependencies: [
.product(name: "Vapor", package: "vapor"),
Expand All @@ -42,13 +42,8 @@ let package = Package(
.product(name: "QueuesRedisDriver", package: "queues-redis-driver"),
.product(name: "Mailgun", package: "mailgun"),
.product(name: "VaporRouting", package: "vapor-routing")
],
swiftSettings: [
.unsafeFlags(["-cross-module-optimization"], .when(configuration: .release))
]
),

.executableTarget(name: "Main", dependencies: [.target(name: "App")]),
.testTarget(name: "AppTests", dependencies: [
.target(name: "App"),
.product(name: "XCTVapor", package: "vapor"),
Expand Down
44 changes: 44 additions & 0 deletions Sources/App/entrypoint.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import Vapor
import Dispatch
import Logging
import MongoQueue

/// 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() }

do {
try await configure(app)
} catch {
app.logger.report(error: error)
throw error
}

try await app.runFromAsyncMainEntrypoint()
}
}


15 changes: 0 additions & 15 deletions Sources/Main/Main.swift

This file was deleted.

0 comments on commit e5dacbd

Please sign in to comment.