krux / starport

Apache License 2.0
2 stars 7 forks source link

fix lambda stdout/stderr #30

Closed talbright closed 5 years ago

talbright commented 5 years ago

This was working before! Perhaps AWS changed something in the Lambda runtime, or I didn't test things well enough. Regardless, I moved the initialization of the IO into static areas, following these best practices:

Limit the re-initialization of variables/objects on every invocation. Instead use static initialization/constructor, global/static variables and singletons. Keep alive and reuse connections (HTTP, database, etc.) that were established during a previous invocation.

Additionally, I'm no longer switching the original stdout/stderr back. These stay re-assigned for the duration of the lambda lifetime. However, I am still printing to the original stderr/stdout so that data appears in cloudwatch logs.