Skip to content

Commit

Permalink
Add debug wait after invocation completes (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Fangl <[email protected]>
  • Loading branch information
dominikschubert and dfangl authored Mar 23, 2023
1 parent f65b6ad commit 0636459
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/localstack/custom_interop.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"go.amzn.com/lambda/rapidcore/standalone"
"io"
"net/http"
"strconv"
"strings"
"time"
)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions cmd/localstack/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type LsOpts struct {
InitLogLevel string
EdgePort string
EnableXRayTelemetry string
PostInvokeWaitMS string
}

func GetEnvOrDie(env string) string {
Expand Down Expand Up @@ -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"),
}
}

Expand All @@ -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
Expand Down

0 comments on commit 0636459

Please sign in to comment.