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

Provide a way to reopen logs. #278

Closed
msapiro opened this issue Aug 3, 2021 · 3 comments
Closed

Provide a way to reopen logs. #278

msapiro opened this issue Aug 3, 2021 · 3 comments

Comments

@msapiro
Copy link

msapiro commented Aug 3, 2021

This is related to #239 but is a different issue.

We use aiosmtpd in Mailman 3 to implement an LMTP server. Our issue is we have several persistent processes that process queues and do other tasks. In order to support log rotation, these processes will close and reopen their log files upon receipt of a SIGHUP. We also arrange for logging to mail.log to be propagated to our smtp.log.

The issue is when we SIGHUP our processes following log rotation, those that write to our smtp.log will close and reopen their logs and begin writing the now current smtp.log, but aiosmtpd continues to write to its prior mail.log which is an older generation of our smtp.log.

We would like some way to tell aiosmtpd to close and reopen its mail.log, or if there is currently a way, what is it?

Also see https://gitlab.com/mailman/mailman/-/issues/931 for our issue on this.

@waynew
Copy link
Collaborator

waynew commented Aug 3, 2021

I think this is a good feature if it's not something we already support.

In theory we should be able to use the rotating file handler, and possibly do a .rotate or something in a signal handler.

@msapiro
Copy link
Author

msapiro commented Aug 3, 2021

I've investigated a bit further, and I think that Python's logging module already handles this. I think the issue in our case is that we propagate aiosmtpd's mail.log to our smtp.log so that when we rotate our smtp.log, aiosmtpd's mail.log doesn't change. I think the solution for us is to ensure that when we rotate logs, we also reopen mail.log.

I will work on this from that angle and report.

@msapiro
Copy link
Author

msapiro commented Aug 4, 2021

I am closing this issue as I don't think it is an issue with aiosmtpd. If a process is using Python's logging module to log to a file and that file is rotated, the logging module detects that and automatically switches to the new file. Our issue with Mailman is because of the way we propagate some third party logs to our own logs. We do it in a way that leaves the original log at stderr which doesn't rotate when we rotate our logs. This may be strictly a Mailman issue or there may be something the logging module can do to detect this, but in any case, I don't believe it's an aiosmtpd issue.

For updates, see our issue at https://gitlab.com/mailman/mailman/-/issues/931.

@msapiro msapiro closed this as completed Aug 4, 2021
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

2 participants