-
Notifications
You must be signed in to change notification settings - Fork 92
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
How to gracefully shutdown smtpd? #27
Comments
When I wrote it initially, the Shutdown function for the built-in HTTP server didn't exist, and there is no current equivalent. If you'd like to submit a pull request, I'd be happy to take a look at it. |
Hello, I'm looking at implementing a graceful shutdown but can't quite get it to work. Here's my code that starts the SMTP listener:
Not shown here, but on Ctrl+C, I was looking at the smtpd source code:
To me it looks like it checks the shutdown condition at the start of the for loop, and then blocks at I also run a HTTP listener (http.Server) in a similar way, and it is able to finish up immediately, without waiting for one extra HTTP request. Perhaps there's a viable way to make smtpd work the same? |
Your analysis makes sense. The Server in the http package has handling for the shutdown after the Accept call which is missing here. Want to have a go at fixing it and sending a pull request? |
I can give it a try, but it would need a thorough review for sure. My knowledge of Go is minimal. |
You mentioned that you modeled it after the built-in http server. It has a Shutdown method for gracefully shutting down the service. How do I do the equivalent with smtpd? Thanks!
The text was updated successfully, but these errors were encountered: