aws/aws-lambda-runtime-interface-emulator

Running RIE with Go-based Lambda + Delve debugger?

skyzyx opened this issue · 1 comments

I'm currently using RIE to run my compiled Go binary.

#!/bin/sh

if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then
    exec /usr/local/bin/aws-lambda-rie /var/runtime/bootstrap
else
    exec /var/runtime/bootstrap
fi

However, I also want to run Delve, the Go debugger, against my binary.

exec dlv exec --headless --listen :4040 /var/runtime/bootstrap

I've tried combining the commands in different ways to get both RIE and Delve to work, to no avail.

Example: Delve first

exec dlv exec --headless --listen :4040 /usr/local/bin/aws-lambda-rie /var/runtime/bootstrap

In this case, Delve tries to debug RIE.

Example: RIE first

exec /usr/local/bin/aws-lambda-rie dlv exec --headless --listen :4040 /var/runtime/bootstrap

In this case, RIE only seems to run Delve during the lifetime of a request to my Lambda function.

Example: Running in background and capturing PID

PID="$(exec /usr/local/bin/aws-lambda-rie /var/runtime/bootstrap &)"

dlv attach --headless --listen :4040 $PID

In this case, RIE doesn't move into the background. It stays in the foreground, and Delve never runs.

Any ideas would be welcome.