File tree Expand file tree Collapse file tree 4 files changed +17
-5
lines changed
packages/hoppscotch-backend/src Expand file tree Collapse file tree 4 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,14 @@ curlCheck() {
88 fi
99}
1010
11+ # Wait for initial startup period to avoid unnecessary error logs
12+ # Check if the container has been running for at least 15 seconds
13+ UPTIME=$( awk ' {print int($1)}' /proc/uptime)
14+ if [ " $UPTIME " -lt 15 ]; then
15+ echo " Container still starting up (uptime: ${UPTIME} s), skipping health check..."
16+ exit 0
17+ fi
18+
1119if [ " $ENABLE_SUBPATH_BASED_ACCESS " = " true" ]; then
1220 curlCheck " http://localhost:${HOPP_AIO_ALTERNATE_PORT:- 80} /backend/ping" || exit 1
1321else
Original file line number Diff line number Diff line change @@ -370,14 +370,16 @@ export async function isInfraConfigTablePopulated(): Promise<boolean> {
370370}
371371
372372/**
373- * Stop the app after 5 seconds
374- * (Docker will re-start the app )
373+ * Stop the app after 5 seconds with graceful shutdown
374+ * (Sends SIGTERM to trigger NestJS graceful shutdown, then Docker container stops )
375375 */
376376export function stopApp ( ) {
377377 console . log ( 'Stopping app in 5 seconds...' ) ;
378378
379379 setTimeout ( ( ) => {
380- console . log ( 'Stopping app now...' ) ;
380+ console . log ( 'Stopping app now with graceful shutdown...' ) ;
381+ // Send SIGTERM to the current process to trigger graceful shutdown
382+ // This will call app.close() which triggers onModuleDestroy lifecycle hooks
381383 process . kill ( process . pid , 'SIGTERM' ) ;
382384 } , 5000 ) ;
383385}
Original file line number Diff line number Diff line change @@ -99,8 +99,10 @@ async function bootstrap() {
9999
100100 // Graceful shutdown
101101 process . on ( 'SIGTERM' , async ( ) => {
102- console . info ( 'SIGTERM signal received' ) ;
102+ console . info ( 'SIGTERM signal received, initiating graceful shutdown... ' ) ;
103103 await app . close ( ) ;
104+ console . info ( 'Application closed successfully' ) ;
105+ process . exit ( 0 ) ;
104106 } ) ;
105107}
106108
Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ COPY aio-subpath-access.Caddyfile /etc/caddy/aio-subpath-access.Caddyfile
183183
184184ENTRYPOINT [ "tini" , "--" ]
185185COPY --chmod=755 healthcheck.sh /
186- HEALTHCHECK --interval=2s CMD /bin/sh /healthcheck.sh
186+ HEALTHCHECK --interval=2s --start-period=15s CMD /bin/sh /healthcheck.sh
187187
188188WORKDIR /dist/backend
189189CMD ["node" , "/usr/src/app/aio_run.mjs" ]
You can’t perform that action at this time.
0 commit comments