Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
feat: zero-downtime using lightship
Browse files Browse the repository at this point in the history
  • Loading branch information
devthejo committed Aug 29, 2023
1 parent c4f71e9 commit c2596bb
Show file tree
Hide file tree
Showing 5 changed files with 482 additions and 11 deletions.
13 changes: 12 additions & 1 deletion .kontinuous/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,18 @@ app:
host: "{{.Values.global.host}}"
imagePackage: app
containerPort: 3000
probesPath: "/healthz"
livenessProbe:
httpGet:
path: /live
port: 9000
startupProbe:
httpGet:
path: /live
port: 9000
readinessProbe:
httpGet:
path: /ready
port: 9000
envFrom:
- configMapRef:
name: app
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"only-include-used-icons": "node node_modules/@codegouvfr/react-dsfr/bin/only-include-used-icons.js",
"dev": "next dev",
"build": "next build",
"start": "next start",
"start": "NEXT_MANUAL_SIG_HANDLE=true next start",
"lint": "next lint",
"prepare": "husky install",
"lint-staged": "lint-staged",
Expand Down Expand Up @@ -38,6 +38,7 @@
"@sentry/nextjs": "^7.60.1",
"@socialgouv/matomo-next": "^1.6.1",
"dayjs": "^1.11.9",
"lightship": "^9.0.2",
"next": "13.4.12",
"next-auth": "^4.22.3",
"react": "18.2.0",
Expand Down
6 changes: 6 additions & 0 deletions src/lib/graceful-shutdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createLightship } from "lightship";

export default async function handleGracefulShutdown() {
const lightship = await createLightship();
lightship.signalReady();
}
3 changes: 3 additions & 0 deletions src/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Html, Head, Main, NextScript, DocumentProps } from "next/document";
import handleGracefulShutdown from "../lib/graceful-shutdown";
import { dsfrDocumentApi, augmentDocumentWithEmotionCache } from "./_app";

const { getColorSchemeHtmlAttributes, augmentDocumentForDsfr } =
Expand Down Expand Up @@ -26,3 +27,5 @@ export default function Document(props: DocumentProps) {
augmentDocumentForDsfr(Document);

augmentDocumentWithEmotionCache(Document);

handleGracefulShutdown();
Loading

0 comments on commit c2596bb

Please sign in to comment.