Enable sd_listen_fds(3)-style socket-activation support

I've added straightforward systemd unit files in
system/socket-activation/ that make use of this approach, and a
README.md in the same location that describes the tradeoffs.
This commit is contained in:
Daniel Kahn Gillmor
2019-02-21 17:12:59 -05:00
parent 25fdd3b81c
commit 7092874729
4 changed files with 65 additions and 1 deletions
+10 -1
View File
@@ -355,7 +355,16 @@ def main():
miltername = 'dkimpy-filter'
socketname = milterconfig.get('Socket')
if socketname is None:
socketname = 'local:/var/run/dkimpy-milter/dkimpy-milter.sock'
if int(os.environ.get('LISTEN_PID', '0')) == os.getpid():
lfds = os.environ.get('LISTEN_FDS')
if lfds is not None:
if lfds != '1':
syslog.syslog('LISTEN_FDS is set to "{0}", but we only know how to deal with "1", ignoring it'.
format(lfds))
else:
socketname = 'fd:3'
if socketname is None:
socketname = 'local:/var/run/dkimpy-milter/dkimpy-milter.sock'
own_socketfile(milterconfig, socketname)
drop_privileges(milterconfig)
sys.stdout.flush()