@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, 04:45 UTC

main
ts 41 lines 1.28 KB
Raw
1 import * as Kubernetes from "@alchemy.run/kubernetes";
2 import * as Output from "alchemy/Output";
3 import * as Effect from "effect/Effect";
4 import * as HttpClient from "effect/http/HttpClient";
5 import * as HttpClientResponse from "effect/http/HttpClientResponse";
6 import * as Schedule from "effect/Schedule";
7 import { Cluster, Namespace, Web } from "./infra.ts";
8
9 export default Kubernetes.Job(
10 "HealthCheck",
11 Effect.gen(function* () {
12 const cluster = yield* Cluster;
13 const namespace = yield* Namespace;
14 return {
15 cluster,
16 main: import.meta.url,
17 name: "health-check",
18 namespace: namespace.name,
19 schedule: "*/5 * * * *",
20 };
21 }),
22 Effect.gen(function* () {
23 const web = yield* Web;
24 const webUrl =
25 yield* Output.interpolate`http://${web.serviceName}.${web.namespace}.svc.cluster.local:${web.port}`;
26
27 return {
28 run: Effect.gen(function* () {
29 const url = yield* webUrl;
30 const response = yield* HttpClient.get(`${url}/healthz`).pipe(
31 Effect.flatMap(HttpClientResponse.filterStatusOk),
32 Effect.retry({
33 schedule: Schedule.exponential("1 second"),
34 times: 5,
35 }),
36 );
37 yield* Effect.log(`${url} responded ${response.status}`);
38 }).pipe(Effect.orDie),
39 };
40 }),
41 );