Skip to content

Feature: Add graceful shutdown handling to API server #76

@Smartdevs17

Description

@Smartdevs17

Problem

The API server in api/src/index.ts doesn't handle graceful shutdown. On SIGTERM/SIGINT, in-flight requests are dropped.

Context

During deployments, requests in progress should complete before the server stops.

Proposed Solution

const server = app.listen(port);

process.on('SIGTERM', () => {
  logger.info('SIGTERM received, shutting down gracefully');
  server.close(() => {
    logger.info('Server closed');
    process.exit(0);
  });
  setTimeout(() => process.exit(1), 10000); // force after 10s
});

Acceptance Criteria

  • SIGTERM triggers graceful shutdown
  • In-flight requests complete before close
  • Force exit after timeout (10s)
  • Shutdown logged

Technical Notes

  • File: api/src/index.ts

Constraints

  • Must work with Vercel serverless (may not apply there)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave programapiREST API componenteasyDifficulty: EasyenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions