From 0b3e37926a3943a102e6ab38e15f0fd8bcf06d2b Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Sat, 4 Oct 2025 02:57:09 +0300 Subject: [PATCH] refactor: update healthcheck command to use wget and reduce shutdown timeout from 10 to 5 seconds --- Dockerfile | 8 ++++---- src/backend/index.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index f1f71cf..95fcd77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,8 +51,8 @@ ENV APP_VERSION=${APP_VERSION} \ GIT_REVISION=${GIT_REVISION} \ NODE_ENV=production -# Install dumb-init for proper signal handling -RUN apk add --no-cache dumb-init +# Install dumb-init for proper signal handling and wget for healthcheck +RUN apk add --no-cache dumb-init wget # Create app directory WORKDIR /app @@ -92,8 +92,8 @@ USER bitip EXPOSE 5172 # Health check -HEALTHCHECK --interval=60s --timeout=3s --start-period=20s --retries=3 \ - CMD node -e "require('http').get('http://localhost:5172/api/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) }).on('error', () => { process.exit(1) })" +HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:5172/api/health || exit 1 # Start the application ENTRYPOINT ["dumb-init", "--"] diff --git a/src/backend/index.ts b/src/backend/index.ts index d3a0084..26a6a99 100644 --- a/src/backend/index.ts +++ b/src/backend/index.ts @@ -136,11 +136,11 @@ const gracefulShutdown = async (signal: string): Promise => { } }); - // Force close after 10 seconds + // Force close after 5 seconds setTimeout(() => { logger.error('Forced shutdown after timeout'); process.exit(1); - }, 10000); + }, 5000); }; process.on('SIGTERM', () => gracefulShutdown('SIGTERM'));