Skip to content

chore: Implement a graceful shutdown sequence for the Node server #43

@AlAfiz

Description

@AlAfiz

Description

When we deploy updates to the backend, the server process is killed abruptly.
If a user's API request is currently processing, it will fail suddenly without a proper response.
We need to implement a "Graceful Shutdown" script that catches termination signals (SIGINT, SIGTERM).
This script should stop accepting new requests and finish processing active requests before shutting down completely.

Requirements

  • Add event listeners for process.on('SIGTERM') and process.on('SIGINT').
  • Inside the listener, call server.close() to stop accepting new HTTP connections.
  • Add a console.log("Gracefully shutting down TradeFlow API...").
  • Use process.exit(0) after the server successfully closes all active connections.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions