|
2 | 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. |
3 | 3 | // See the LICENSE file in the project root for more information |
4 | 4 |
|
5 | | -using System.Text.Json.Serialization; |
6 | | -using Amazon.Lambda.APIGatewayEvents; |
7 | | -using Amazon.Lambda.Serialization.SystemTextJson; |
8 | | -using Elastic.Documentation.Api.Core.AskAi; |
9 | | -using Elastic.Documentation.Api.Core.Search; |
10 | 5 | using Elastic.Documentation.Api.Infrastructure; |
11 | 6 | using Elastic.Documentation.ServiceDefaults; |
12 | 7 | using Microsoft.Extensions.Logging; |
|
53 | 48 | process.Refresh(); |
54 | 49 | Console.WriteLine($"Elastic OTel configured. Memory: {process.WorkingSet64 / 1024 / 1024} MB"); |
55 | 50 |
|
56 | | - _ = builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi, new SourceGeneratorLambdaJsonSerializer<LambdaJsonSerializerContext>()); |
| 51 | + // Configure Kestrel to listen on port 8080 for Lambda Web Adapter |
| 52 | + // Lambda Web Adapter expects the app to run as a standard HTTP server on localhost:8080 |
| 53 | + _ = builder.WebHost.ConfigureKestrel(serverOptions => |
| 54 | + { |
| 55 | + serverOptions.ListenLocalhost(8080); |
| 56 | + }); |
57 | 57 | process.Refresh(); |
58 | | - Console.WriteLine($"AWS Lambda hosting configured. Memory: {process.WorkingSet64 / 1024 / 1024} MB"); |
| 58 | + Console.WriteLine($"Kestrel configured to listen on port 8080. Memory: {process.WorkingSet64 / 1024 / 1024} MB"); |
59 | 59 |
|
60 | 60 | var environment = Environment.GetEnvironmentVariable("ENVIRONMENT"); |
61 | 61 | Console.WriteLine($"Environment: {environment}"); |
|
64 | 64 | process.Refresh(); |
65 | 65 | Console.WriteLine($"Elastic docs API use cases added. Memory: {process.WorkingSet64 / 1024 / 1024} MB"); |
66 | 66 |
|
67 | | - _ = builder.WebHost.UseKestrelHttpsConfiguration(); |
68 | | - process.Refresh(); |
69 | | - Console.WriteLine($"Kestrel HTTPS configuration applied. Memory: {process.WorkingSet64 / 1024 / 1024} MB"); |
70 | | - |
71 | 67 | var app = builder.Build(); |
72 | 68 | process.Refresh(); |
73 | 69 | Console.WriteLine($"Application built successfully. Memory: {process.WorkingSet64 / 1024 / 1024} MB"); |
|
86 | 82 | Console.WriteLine($"Stack trace: {ex.StackTrace}"); |
87 | 83 | throw; |
88 | 84 | } |
89 | | - |
90 | | -[JsonSerializable(typeof(APIGatewayHttpApiV2ProxyRequest))] |
91 | | -[JsonSerializable(typeof(APIGatewayHttpApiV2ProxyResponse))] |
92 | | -[JsonSerializable(typeof(AskAiRequest))] |
93 | | -[JsonSerializable(typeof(SearchRequest))] |
94 | | -[JsonSerializable(typeof(SearchResponse))] |
95 | | -internal sealed partial class LambdaJsonSerializerContext : JsonSerializerContext; |
0 commit comments