[Remail] Triggering welcome emails on list.yaml changes

Thomas Gleixner tglx at linutronix.de
Sun Sep 13 22:57:09 CEST 2020


Konstantin,

On Wed, Sep 09 2020 at 10:46, Konstantin Ryabitsev wrote:
> What is the proper way to trigger sending out welcome emails on changes 
> to the repository containing list.yaml? Currently, those welcome emails 
> don't get sent out until someone sends an actual email to the list, 
> which is not what list admins are expecting.
>
> In our setup, we don't have a daemon running -- deliveries are happening 
> via a procmail trigger.

and because there is no daemon the welcome mails are not sent until
actual mail processing happens. Never thought about that. My setup used
the daemon...

Seomthing like the completely untested below should allow you to just
invoke:

        remail_pipe -c ... site.yaml

after any of the configuration files has been updated.

The processing of the updated config files is serialized against a
concurrent mail delivery via the lock file in the work directory, so no
extra serialization required. Whatever happens first sends out the
welcome mails.

Thanks,

        tglx
---
diff --git a/Documentation/man1/remail_pipe.rst b/Documentation/man1/remail_pipe.rst
index 1c91604bb25c..8077c6a12d8f 100644
--- a/Documentation/man1/remail_pipe.rst
+++ b/Documentation/man1/remail_pipe.rst
@@ -24,6 +24,14 @@ Options
 -h, --help
    Show this help message and exit
 
+-c, --cfgupdate
+   Read the configuration update and do not process mail from stdin. That
+   allows to send out welcome mails after a list configuration file was
+   updated. Otherwise the welcome mails are delayed until actual mail
+   delivery happens. The update and welcome mail processing is serialized
+   via the lock file in the working directory; no external serialization
+   against a concurrent mail delivery required.
+
 -s syslog, --syslog
    Use syslog for logging. Default is stderr
 
@@ -59,7 +67,7 @@ Exit codes
 .. list-table::
 
    * - 0
-     - Mail was successfully delivered
+     - Mail was successfully delivered or config update was successful
    * - 1
      - No enabled mailinglist found for delivery
    * - 2
diff --git a/remail/remaild.py b/remail/remaild.py
index bbe580363723..3f577cfc8be0 100644
--- a/remail/remaild.py
+++ b/remail/remaild.py
@@ -370,13 +370,16 @@ class remaild(object):
         return self.should_stop()
 
     # The pipe handling interface
-    def handle_pipe(self):
+    def handle_pipe(self, cfgupdate):
         self._should_reload = True
         self.reconfigure()
 
         if not self.enabled:
             return 1
 
+        if cfgupdate:
+            return 0
+
         policy = EmailPolicy(utf8=True)
         msg = message_from_file(sys.stdin, policy=policy)
         return self.process_msg(msg, 'pipe input')
diff --git a/remail_pipe b/remail_pipe
index 4e4c1b437bf5..9d8e2d936560 100755
--- a/remail_pipe
+++ b/remail_pipe
@@ -19,6 +19,8 @@ def exit_daemon(logger, res):
 if __name__ == '__main__':
     parser = ArgumentParser(description='remail pipe')
     parser.add_argument('config', help='Config file')
+    parser.add_argument('--cfgupdate', '-c', dest='update', action='store_true',
+                        help='Handle config file update. No mail processing.')
     parser.add_argument('--syslog', '-s', dest='syslog', action='store_true',
                         help='Use syslog for logging. Default is stderr')
     parser.add_argument('--verbose', '-v', dest='verbose', action='store_true',
@@ -46,7 +48,7 @@ if __name__ == '__main__':
         exit_daemon(logger, 11)
 
     try:
-        res = rd.handle_pipe()
+        res = rd.handle_pipe(args.cfgupdate)
     except Exception as ex:
         '''
         Exceptions which reach here are fatal



More information about the Remail mailing list