mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
Every running Lambda container held a /wait stream, a streaming connection and a thread, only to notice its runtime exiting. With floci.docker.events-exit-detection on (off by default), DockerExitEvents watches them all through one events subscription filtered to container die events, as the AWS ECS agent does. Because events are edge-triggered, a container is registered before it starts and the first subscription is confirmed before the registration returns; after the stream drops, it subscribes again and inspects every watched container, reporting the ones that exited or died in the gap and never one still being created. The exit code comes from an inspect, with the event's exitCode attribute as the fallback, and each exit is reported once, on a virtual thread. With the flag off, LambdaExitWatcher runs as before. A dropped or unconfirmed stream marks a sweep that the next subscription to start runs, whoever opened it. An inspect in the sweep that fails with anything but NotFound is tried again on a doubling delay, and only a subscription Docker confirms resets the reconnect backoff. Signed-off-by: Hector Ventura <hectorvent@gmail.com>