[pmg-devel] [RFC pmg-api] Reload postfix instead of restart
Stoiko Ivanov
s.ivanov at proxmox.com
Tue Apr 9 18:13:17 CEST 2019
>From `man 1 postfix`:
```
Note: in order to refresh the Postfix mail system after a configuration change,
do not use the start and stop commands in succession. Use the reload command
instead.
```
Additionally restarting postfix, while a mail has been passed to pmg-smtp-filter
but has not beed fed back to postfix again, causes it to get passed a second
time to pmg-smtp-filter (by qmgr) and this results in duplicate maildelivery
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
I hope I did not overlook a usecase for restart vs. reload here.
Tested that a `systemctl reload postfix` (and `postfix reload`) e.g. does
change the listening port of a smtpd service
Example log from a restart causing a mail to be handed twice to pmg-smtp-filter:
```
Apr 9 16:19:50 pmg5 postfix/smtpd[12786]: connect from unknown[192.0.2.70]
Apr 9 16:19:50 pmg5 postfix/smtpd[12786]: D5E936052B: client=unknown[192.0.2.70]
Apr 9 16:19:50 pmg5 postfix/cleanup[12791]: D5E936052B: message-id=<20190409160909 at test.proxmox.com>
Apr 9 16:19:51 pmg5 postfix/smtpd[12786]: disconnect from unknown[192.0.2.70] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Apr 9 16:19:51 pmg5 postfix/qmgr[846]: D5E936052B: from=<siv at sender.test.example>, size=49407, nrcpt=1 (queue active)
Apr 9 16:19:51 pmg5 pmg-smtp-filter[12769]: 2019/04/09-16:19:51 CONNECT TCP Peer: "[127.0.0.1]:48146" Local: "[127.0.0.1]:10024"
Apr 9 16:19:51 pmg5 pmg-smtp-filter[12769]: 6325F5CACAA0765951: new mail message-id=<20190409160909 at test.proxmox.com>
Apr 9 16:19:56 pmg5 postfix/postfix-script[12809]: stopping the Postfix mail system
Apr 9 16:19:56 pmg5 postfix/postfix-script[12812]: waiting for the Postfix mail system to terminate
Apr 9 16:19:56 pmg5 postfix/master[844]: terminating on signal 15
Apr 9 16:19:57 pmg5 postfix/postfix-script[12975]: starting the Postfix mail system
Apr 9 16:19:57 pmg5 postfix/master[12977]: daemon started -- version 3.1.9, configuration /etc/postfix
Apr 9 16:19:57 pmg5 postfix/qmgr[12979]: D5E936052B: from=<siv at sender.test.example>, size=49407, nrcpt=1 (queue active)
Apr 9 16:19:57 pmg5 pmg-smtp-filter[12759]: Starting "1" children
Apr 9 16:19:57 pmg5 pmg-smtp-filter[12768]: 2019/04/09-16:19:57 CONNECT TCP Peer: "[127.0.0.1]:48148" Local: "[127.0.0.1]:10024"
Apr 9 16:19:57 pmg5 pmg-smtp-filter[12759]: starting database maintainance
Apr 9 16:19:57 pmg5 pmg-smtp-filter[12759]: end database maintainance (24 ms)
Apr 9 16:19:57 pmg5 pmg-smtp-filter[12768]: 632615CACAA0D914B3: new mail message-id=<20190409160909 at test.proxmox.com>
```
PMG/API2/MyNetworks.pm | 4 ++--
PMG/Config.pm | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/PMG/API2/MyNetworks.pm b/PMG/API2/MyNetworks.pm
index 8394096..975ca2e 100644
--- a/PMG/API2/MyNetworks.pm
+++ b/PMG/API2/MyNetworks.pm
@@ -92,7 +92,7 @@ __PACKAGE__->register_method ({
my $cfg = PMG::Config->new();
if ($cfg->rewrite_config_postfix()) {
- PMG::Utils::service_cmd('postfix', 'restart');
+ PMG::Utils::service_cmd('postfix', 'reload');
}
};
@@ -212,7 +212,7 @@ __PACKAGE__->register_method ({
my $cfg = PMG::Config->new();
if ($cfg->rewrite_config_postfix()) {
- PMG::Utils::service_cmd('postfix', 'restart');
+ PMG::Utils::service_cmd('postfix', 'reload');
}
};
diff --git a/PMG/Config.pm b/PMG/Config.pm
index b2e1c6c..9f1c001 100755
--- a/PMG/Config.pm
+++ b/PMG/Config.pm
@@ -1552,7 +1552,7 @@ sub rewrite_config {
if (($self->rewrite_config_postfix($rulecache) && $restart_services) ||
$force_restart->{postfix}) {
- PMG::Utils::service_cmd('postfix', 'restart');
+ PMG::Utils::service_cmd('postfix', 'reload');
}
if ($self->rewrite_dot_forward() && $restart_services) {
--
2.11.0
More information about the pmg-devel
mailing list