Skip to content

Commit 0636459

Browse files
Add debug wait after invocation completes (#16)
Co-authored-by: Daniel Fangl <[email protected]>
1 parent f65b6ad commit 0636459

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cmd/localstack/custom_interop.go

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"go.amzn.com/lambda/rapidcore/standalone"
1313
"io"
1414
"net/http"
15+
"strconv"
1516
"strings"
1617
"time"
1718
)
@@ -139,6 +140,14 @@ func NewCustomInteropServer(lsOpts *LsOpts, delegate rapidcore.InteropServer, lo
139140
log.Fatalln(err)
140141
}
141142
}
143+
// optional sleep. can be used for debugging purposes
144+
if lsOpts.PostInvokeWaitMS != "" {
145+
waitMS, err := strconv.Atoi(lsOpts.PostInvokeWaitMS)
146+
if err != nil {
147+
log.Fatalln(err)
148+
}
149+
time.Sleep(time.Duration(waitMS) * time.Millisecond)
150+
}
142151
timeoutDuration := time.Duration(timeout) * time.Second
143152
memorySize := GetEnvOrDie("AWS_LAMBDA_FUNCTION_MEMORY_SIZE")
144153
PrintEndReports(invokeR.InvokeId, "", memorySize, invokeStart, timeoutDuration, logCollector)

cmd/localstack/main.go

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type LsOpts struct {
2727
InitLogLevel string
2828
EdgePort string
2929
EnableXRayTelemetry string
30+
PostInvokeWaitMS string
3031
}
3132

3233
func GetEnvOrDie(env string) string {
@@ -54,6 +55,7 @@ func InitLsOpts() *LsOpts {
5455
EnableDnsServer: os.Getenv("LOCALSTACK_ENABLE_DNS_SERVER"),
5556
EnableXRayTelemetry: os.Getenv("LOCALSTACK_ENABLE_XRAY_TELEMETRY"),
5657
LocalstackIP: os.Getenv("LOCALSTACK_HOSTNAME"),
58+
PostInvokeWaitMS: os.Getenv("LOCALSTACK_POST_INVOKE_WAIT_MS"),
5759
}
5860
}
5961

@@ -71,6 +73,8 @@ func UnsetLsEnvs() {
7173
"LOCALSTACK_ENABLE_DNS_SERVER",
7274
"LOCALSTACK_ENABLE_XRAY_TELEMETRY",
7375
"LOCALSTACK_INIT_LOG_LEVEL",
76+
"LOCALSTACK_POST_INVOKE_WAIT_MS",
77+
7478
// Docker container ID
7579
"HOSTNAME",
7680
// User

0 commit comments

Comments
 (0)