Skip to content

Conversation

wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Jul 24, 2025

Continuing on #1027

This PR also gracefully shutdown the infinite loop on process kill.

A little refactoring has been added to avoid code duplication, and centralize loop and shutdown management in 2 new helpers

@wa0x6e wa0x6e requested a review from Copilot July 24, 2025 14:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements graceful shutdown functionality for the application by adding signal handlers for SIGINT and SIGTERM that properly close the Express server and database connections before terminating the process.

Key changes:

  • Added graceful shutdown handlers for SIGINT and SIGTERM signals
  • Implemented database connection pool cleanup functionality
  • Refactored server initialization to capture server instance for controlled shutdown

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/index.ts Added graceful shutdown function and signal handlers to properly close server and database connections
src/helpers/mysql.ts Implemented closeDatabase function to properly close MySQL connection pools

@wa0x6e wa0x6e force-pushed the perf-graceful-shutdown-of-infinite-loop branch from eacb5ec to b8b5a26 Compare July 24, 2025 14:17
@wa0x6e wa0x6e changed the base branch from master to graceful-shutdown July 24, 2025 14:20
@wa0x6e wa0x6e requested a review from ChaituVR July 24, 2025 14:21
Base automatically changed from graceful-shutdown to master July 24, 2025 17:10
@wa0x6e
Copy link
Contributor Author

wa0x6e commented Aug 29, 2025

Will reopen if we notice some stray processes again

@wa0x6e wa0x6e closed this Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants