Skip to content

Conversation

Andrea-Scuderi
Copy link
Member

  • Remove redundant BreezeLambdaService

@Andrea-Scuderi
Copy link
Member Author

Graceful shutdown logs:

andreascuderi@192 BreezeLambdaDynamoDBAPI % swift run
Building for debugging...
[10/10] Applying BreezeLambdaItemAPI
Build of product 'BreezeLambdaItemAPI' complete! (3.01s)
2025-10-02T22:25:54+0100 info service-group-breeze-lambda-api : [BreezeDynamoDBService] Init DynamoDBService with config...
2025-10-02T22:25:54+0100 info service-group-breeze-lambda-api : [BreezeDynamoDBService] region: us-east-1
2025-10-02T22:25:54+0100 info service-group-breeze-lambda-api : [BreezeDynamoDBService] tableName: Breeze
2025-10-02T22:25:54+0100 info service-group-breeze-lambda-api : [BreezeDynamoDBService] keyName: itemKey
2025-10-02T22:25:54+0100 info service-group-breeze-lambda-api : [BreezeDynamoDBService] DBManager is ready.
2025-10-02T22:25:54+0100 info service-group-breeze-lambda-api : [BreezeLambdaAPI] Starting BreezeLambdaAPI...
2025-10-02T22:25:54+0100 info LambdaRuntime : host="127.0.0.1" port=7000 [AWSLambdaRuntime] Server started and listening
^C2025-10-02T22:26:07+0100 info service-group-breeze-lambda-api : [BreezeDynamoDBService] Stopping DynamoDBService...
2025-10-02T22:26:07+0100 info service-group-breeze-lambda-api : [BreezeDynamoDBService] DynamoDBService is stopped.
2025-10-02T22:26:07+0100 info service-group-breeze-lambda-api : [BreezeDynamoDBService] Stopping HTTPClient...
2025-10-02T22:26:07+0100 info service-group-breeze-lambda-api : [BreezeDynamoDBService] HTTPClient is stopped.
2025-10-02T22:26:07+0100 info LambdaRuntime : [AWSLambdaRuntime] Server shutting down
2025-10-02T22:26:07+0100 error LambdaRuntime : [AWSLambdaRuntime] Error during server shutdown: ioOnClosedChannel
2025-10-02T22:26:07+0100 info service-group-breeze-lambda-api : [BreezeLambdaAPI] BreezeLambdaAPI is stopped successfully
andreascuderi@192 BreezeLambdaDynamoDBAPI % 

return self.dbManager
public func run() async throws {
try await gracefulShutdown()
try await onGracefulShutdown()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you shutting down immediately at run() ? Does it work ? Why ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function try await gracefulShutdown() waits until graceful shutdown is triggered as documented in ServiceLifecycle

https://swiftpackageindex.com/swift-server/swift-service-lifecycle/main/documentation/servicelifecycle/gracefulshutdown()

Copy link

@sebsto sebsto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great ! I have a few questions although :-)

do {
try await serviceGroup.run()
} catch {
try dynamoDBService.syncShutdown()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the life cycle group must do that. You should not shutdown() or cancel() a service part of the group

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it does unless there is a failure condition. Without this BreezeLambdaAPITests will crash.
I'll check if there is a better way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants