Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Startup/Ready-, Shutdown-hooks and maybe a /health endpoint #420

Open
philippviereck opened this issue Sep 2, 2024 · 0 comments

Comments

@philippviereck
Copy link

Current Situation

As far as I understand ZoneMTA currently lacks a built-in health check system. While the Zone status (http://localhost:8080/counter/zone/) may be used, it's not clear from my understanding if this truly indicates ZoneMTA's readiness to send emails.

I'm using ZoneMTA behind Traefik for zero-downtime blue-green deployments, and a reliable health check is crucial for this setup.

Requested Feature

Implement hooks for a comprehensive health check system that verifies the entire email pipeline is functioning correctly (including setup outside of ZoneMTA itself). This system needs:

  1. A startup hook that runs as soon as ZoneMTA is ready to start processing emails.
  2. An optional shutdown hook for cleanup operations.
  3. (A dedicated health check endpoint that accurately reflects ZoneMTA's operational status.)

Use Case

This feature would enable more reliable deployments, especially in scenarios like blue-green deployments, by ensuring that new instances are fully operational before being added to the load balancer.

Benefits

  • Improved reliability in various deployment scenarios
  • Reduced risk of serving traffic to partially operational instances
  • Enhanced ability to detect and respond to issues in the email pipeline
  • Better integration with container orchestration and service discovery systems

Proposed Implementation Details

  1. Startup Hook:

    • Configurable through ZoneMTA's configuration file
    • Triggered when core services are initialized
  2. Shutdown Hook:

    • Configurable cleanup operations to be performed when an instance is being taken out of service
  3. Health Check Endpoint:

    • A new /health endpoint that returns detailed status information
    • Should include checks for critical components (e.g., database connections, queue status)

What I'm trying to do

I was thinking that on Startup as soon as ZoneMTA is ready it would add's itself to my database with an ID and send an email to a test inbox. When I was able to receive the email I automatically mark the the instance healthy in the database.
On termination of the instance I would remove the database entry.

A /health endpoint could be useful but I think it's better to test the whole pipeline like I described and have the /health endpoint return 2xx if the instance is marked as healthy in the database and a NOT 2xx response otherwise.

I can try to create a PR for this feature if it aligns with the project's goals.

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

No branches or pull requests

1 participant