[PR #5494] [MERGED] fix: ensure graceful shutdown and container stop when stopApp is called #5237

Closed
opened 2026-03-17 02:42:18 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5494
Author: @mirarifhasan
Created: 10/18/2025
Status: Merged
Merged: 10/21/2025
Merged by: @mirarifhasan

Base: nextHead: fix/graceful-shutdown-on-app-stop


📝 Commits (2)

  • a19b6c9 fix: graceful shutdown handling for backend app
  • 5a54c13 chore: add startup delay to health check script

📊 Changes

4 files changed (+17 additions, -5 deletions)

View changed files

📝 healthcheck.sh (+8 -0)
📝 packages/hoppscotch-backend/src/infra-config/helper.ts (+5 -3)
📝 packages/hoppscotch-backend/src/main.ts (+3 -1)
📝 prod.Dockerfile (+1 -1)

📄 Description

Closes BE-666

What's changed

This pull request improves the application's shutdown process by ensuring a graceful shutdown when stopping the app, particularly in Docker environments. The changes enhance logging for better observability and update the shutdown mechanism to properly trigger NestJS lifecycle hooks.

Graceful shutdown improvements:

  • Updated the stopApp function in helper.ts to send a SIGTERM signal to the process, triggering NestJS's graceful shutdown and ensuring lifecycle hooks are called. Also improved logging to clarify the shutdown process.
  • Enhanced the SIGTERM handler in main.ts to provide more informative logs during shutdown, confirm successful application closure, and explicitly exit the process after shutdown is complete.

Notes to reviewers

You can modify any infrastructure configurations from the admin dashboard.
Please note that the backend Docker container will automatically restart and become available to serve API requests.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5494 **Author:** [@mirarifhasan](https://github.com/mirarifhasan) **Created:** 10/18/2025 **Status:** ✅ Merged **Merged:** 10/21/2025 **Merged by:** [@mirarifhasan](https://github.com/mirarifhasan) **Base:** `next` ← **Head:** `fix/graceful-shutdown-on-app-stop` --- ### 📝 Commits (2) - [`a19b6c9`](https://github.com/hoppscotch/hoppscotch/commit/a19b6c9738cfbed78668d0b593218f3591113658) fix: graceful shutdown handling for backend app - [`5a54c13`](https://github.com/hoppscotch/hoppscotch/commit/5a54c13654bb329a13a7fe2db636c1ccd1152cce) chore: add startup delay to health check script ### 📊 Changes **4 files changed** (+17 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `healthcheck.sh` (+8 -0) 📝 `packages/hoppscotch-backend/src/infra-config/helper.ts` (+5 -3) 📝 `packages/hoppscotch-backend/src/main.ts` (+3 -1) 📝 `prod.Dockerfile` (+1 -1) </details> ### 📄 Description <!-- Thanks for creating this pull request 🤗 Please make sure that the pull request is limited to one type (docs, feature, etc.) and keep it as small as possible. You can open multiple prs instead of opening a huge one. --> <!-- If this pull request closes an issue, please mention the issue number below --> <!-- Issue # here --> Closes BE-666 <!-- Add an introduction into what this PR tries to solve in a couple of sentences --> ### What's changed <!-- Describe point by point the different things you have changed in this PR --> This pull request improves the application's shutdown process by ensuring a graceful shutdown when stopping the app, particularly in Docker environments. The changes enhance logging for better observability and update the shutdown mechanism to properly trigger NestJS lifecycle hooks. **Graceful shutdown improvements:** * Updated the `stopApp` function in `helper.ts` to send a SIGTERM signal to the process, triggering NestJS's graceful shutdown and ensuring lifecycle hooks are called. Also improved logging to clarify the shutdown process. * Enhanced the SIGTERM handler in `main.ts` to provide more informative logs during shutdown, confirm successful application closure, and explicitly exit the process after shutdown is complete. <!-- You can also choose to add a list of changes and if they have been completed or not by using the markdown to-do list syntax - [ ] Not Completed - [x] Completed --> ### Notes to reviewers <!-- Any information you feel the reviewer should know about when reviewing your PR --> You can modify any infrastructure configurations from the admin dashboard. Please note that the backend Docker container will automatically restart and become available to serve API requests. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:42:18 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5237
No description provided.