Skip to content

Add graceful shutdown handling for process signals #16

Description

@cubrift

Problem

Quart does not currently handle SIGINT or SIGTERM. Stopping the process can leave the Baileys socket, QR web server, and SQLite connection to be cleaned up only by the operating system.

This makes local development and process-manager deployments less predictable and can leave in-memory state or pending writes without a deliberate shutdown path.

Expected behavior

A normal shutdown signal should stop active services cleanly and then exit without triggering a reconnect.

Suggested direction

Keep a reference to the active socket, add a small shutdown function, call stopQRHost(), close the database through an exported helper, and guard the connection-close handler so it does not reconnect during shutdown.

Acceptance criteria

  • SIGINT and SIGTERM invoke the same idempotent shutdown path.
  • The QR server and database are closed when they are active.
  • Shutdown does not start a new WhatsApp connection.
  • A second signal or repeated shutdown call is harmless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    codexUse for codex-generated issues only.enhancementPerformance update or requestgood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions