Skip to content

Commit 338cb64

Browse files
authored
feat: add health check (#9)
1 parent 4cd8c61 commit 338cb64

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

bun.lockb

6.86 KB
Binary file not shown.

docker-compose.yml

+5
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ services:
1111
- ./.storage/cache:/worker/cache
1212
ports:
1313
- "8080:8080"
14+
healthcheck:
15+
test: ["CMD", "wget", "-qO-", "http://localhost:8080/health"]
16+
interval: 15s
17+
timeout: 10s
18+
retries: 3

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"typescript": "^5.7.2",
1414
"wrangler": "^3.99.0"
1515
},
16+
"devDependencies": {
17+
"selflare": "^1.1.2"
18+
},
1619
"scripts": {
1720
"build": "selflare compile",
1821
"start": "wrangler dev src/index.ts --local=true",

src/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,11 @@ export default {
810810
env: Env,
811811
ctx: ExecutionContext
812812
): Promise<Response> {
813+
const url = new URL(request.url)
814+
if (url.pathname === "/health") {
815+
return new Response("OK", { status: 200 });
816+
}
817+
813818
const bound = new BoundEnv(env);
814819
return handleRequest(request, bound).catch(handleError);
815820
},

worker.capnp

-8.49 KB
Binary file not shown.

0 commit comments

Comments
 (0)