@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 37 lines 1.33 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import * as Duration from "effect/Duration";
3 import * as Effect from "effect/Effect";
4 import * as HttpServerResponse from "effect/http/HttpServerResponse";
5
6 /**
7 * Probe for Lambda's Shutdown phase.
8 *
9 * The init closure registers an instance-scope finalizer that writes a
10 * marker to stdout (→ CloudWatch): the generated entry registers an
11 * internal extension, so Lambda grants the runtime a 500 ms SIGTERM window
12 * at sandbox spin-down in which the entry closes the instance scope — the
13 * marker appears exactly once per sandbox, never per invocation.
14 *
15 * The fetch handler registers a request-scope finalizer whose marker must
16 * appear once per invocation (the dispatch settles the request scope
17 * inline before returning).
18 */
19 export default class ShutdownProbe extends AWS.Lambda.Function<ShutdownProbe>()(
20 "ShutdownProbe",
21 {
22 main: import.meta.url,
23 functionUrl: true,
24 timeout: Duration.seconds(10),
25 },
26 Effect.gen(function* () {
27 yield* Effect.addFinalizer(() => Effect.sync(() => console.log("ALCHEMY_INSTANCE_FINALIZED")));
28 return {
29 fetch: Effect.gen(function* () {
30 yield* Effect.addFinalizer(() =>
31 Effect.sync(() => console.log("ALCHEMY_REQUEST_FINALIZED")),
32 );
33 return HttpServerResponse.text("ok");
34 }),
35 };
36 }),
37 ) {}