aws-lambda-extensions icon indicating copy to clipboard operation
aws-lambda-extensions copied to clipboard

SIGTERM in custom-runtime-extension-demo

Open ianic opened this issue 4 years ago • 2 comments

I'm analyzing (and playing with) code in the custom-runtime-extension-demo and can't understand when the runtime gets SIGTERM. So far I understand that in line 41 code starts waiting for curl to finish. That is start of new invocation. There we also trap SIGTERM. But I can't got that _term function to be executed ever. It seams that the runtimes gets KILL instead of TERM signal. So this example may be a bit misleading.

@julianwood can you please help me understand that runtime behavior a little bit more. Thanks.

ianic avatar Jan 21 '22 09:01 ianic

The above observation holds true when there are no extensions registered. When I add extension layer then the runtime receives SIGTERM. So there are two different behavior of the runtime (bootstrap) in the provided.al2 Lambda.

When there are no extensions then the bootstrap, which is frozen waiting for /next invocation, gets killed when the Lambda process environment is shutting down. Without getting SIGTERM. If we register extension then we also have a chance to catch SIGTERM in the bootstrap.

Am I observing this correctly.

ianic avatar Jan 21 '22 14:01 ianic

Hi, When there is at least one extension registered (internal or external) the runtime gets SIGTERM on shut down, otherwise it gets SIGKILL. This is the behaviour that is expected currently.

julianwood avatar Jul 05 '22 09:07 julianwood