diff --git a/cmd/localstack/custom_interop.go b/cmd/localstack/custom_interop.go index 35831fa..5ed7895 100644 --- a/cmd/localstack/custom_interop.go +++ b/cmd/localstack/custom_interop.go @@ -12,6 +12,7 @@ import ( "go.amzn.com/lambda/rapidcore/standalone" "io" "net/http" + "strconv" "strings" "time" ) @@ -139,6 +140,14 @@ func NewCustomInteropServer(lsOpts *LsOpts, delegate rapidcore.InteropServer, lo log.Fatalln(err) } } + // optional sleep. can be used for debugging purposes + if lsOpts.PostInvokeWaitMS != "" { + waitMS, err := strconv.Atoi(lsOpts.PostInvokeWaitMS) + if err != nil { + log.Fatalln(err) + } + time.Sleep(time.Duration(waitMS) * time.Millisecond) + } timeoutDuration := time.Duration(timeout) * time.Second memorySize := GetEnvOrDie("AWS_LAMBDA_FUNCTION_MEMORY_SIZE") PrintEndReports(invokeR.InvokeId, "", memorySize, invokeStart, timeoutDuration, logCollector) diff --git a/cmd/localstack/main.go b/cmd/localstack/main.go index baafc37..0a2bf45 100644 --- a/cmd/localstack/main.go +++ b/cmd/localstack/main.go @@ -27,6 +27,7 @@ type LsOpts struct { InitLogLevel string EdgePort string EnableXRayTelemetry string + PostInvokeWaitMS string } func GetEnvOrDie(env string) string { @@ -54,6 +55,7 @@ func InitLsOpts() *LsOpts { EnableDnsServer: os.Getenv("LOCALSTACK_ENABLE_DNS_SERVER"), EnableXRayTelemetry: os.Getenv("LOCALSTACK_ENABLE_XRAY_TELEMETRY"), LocalstackIP: os.Getenv("LOCALSTACK_HOSTNAME"), + PostInvokeWaitMS: os.Getenv("LOCALSTACK_POST_INVOKE_WAIT_MS"), } } @@ -71,6 +73,8 @@ func UnsetLsEnvs() { "LOCALSTACK_ENABLE_DNS_SERVER", "LOCALSTACK_ENABLE_XRAY_TELEMETRY", "LOCALSTACK_INIT_LOG_LEVEL", + "LOCALSTACK_POST_INVOKE_WAIT_MS", + // Docker container ID "HOSTNAME", // User