From d344e1a59f9590872d6efbac24f43ab4bf70d3c0 Mon Sep 17 00:00:00 2001 From: Tim Stallard Date: Fri, 13 Aug 2021 13:15:19 +0100 Subject: [PATCH] use systemd socket activation for sympl-mail-poppassd, fixes #315 --- mail/debian/changelog | 6 ++++++ mail/debian/rules | 2 +- .../sympl-mail.sympl-mail-poppassd.service | 3 --- .../sympl-mail.sympl-mail-poppassd.socket | 8 +++++++ mail/sbin/sympl-mail-poppassd | 21 +++++++------------ 5 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 mail/debian/sympl-mail.sympl-mail-poppassd.socket diff --git a/mail/debian/changelog b/mail/debian/changelog index 1ba49aed..c543353b 100644 --- a/mail/debian/changelog +++ b/mail/debian/changelog @@ -1,3 +1,9 @@ +sympl-mail (11.20210813.0) stable; urgency=medium + + * use systemd socket activation for sympl-mail-poppassd, fixes #315 + + -- Tim Stallard Fri, 13 Aug 2021 14:24:33 +0100 + sympl-mail (11.20210408.0) stable; urgency=medium * Spam tagging now works as expected, prefixing the subject of accepted diff --git a/mail/debian/rules b/mail/debian/rules index 7daa3a0b..fdfb7b62 100755 --- a/mail/debian/rules +++ b/mail/debian/rules @@ -24,7 +24,7 @@ override_dh_auto_clean: override_dh_systemd_enable: dh_systemd_enable -psympl-mail --name sympl-mail-dict-proxy sympl-mail-dict-proxy.service - dh_systemd_enable -psympl-mail --name sympl-mail-poppassd sympl-mail-poppassd.service + dh_systemd_enable -psympl-mail --name sympl-mail-poppassd sympl-mail-poppassd.socket override_dh_installinit: dh_installinit -R --name sympl-mail-dict-proxy diff --git a/mail/debian/sympl-mail.sympl-mail-poppassd.service b/mail/debian/sympl-mail.sympl-mail-poppassd.service index 6c212870..c6320b86 100644 --- a/mail/debian/sympl-mail.sympl-mail-poppassd.service +++ b/mail/debian/sympl-mail.sympl-mail-poppassd.service @@ -5,6 +5,3 @@ Description=Sympl: mail poppass daemon Type=simple ExecStart=/usr/sbin/sympl-mail-poppassd Restart=always - -[Install] -WantedBy=multi-user.target diff --git a/mail/debian/sympl-mail.sympl-mail-poppassd.socket b/mail/debian/sympl-mail.sympl-mail-poppassd.socket new file mode 100644 index 00000000..b73ef9a2 --- /dev/null +++ b/mail/debian/sympl-mail.sympl-mail-poppassd.socket @@ -0,0 +1,8 @@ +[Unit] +Description=Sympl: mail poppass listener + +[Socket] +ListenStream=127.0.0.1:106 + +[Install] +WantedBy=sockets.target diff --git a/mail/sbin/sympl-mail-poppassd b/mail/sbin/sympl-mail-poppassd index b6ce9335..848223e4 100755 --- a/mail/sbin/sympl-mail-poppassd +++ b/mail/sbin/sympl-mail-poppassd @@ -84,23 +84,18 @@ syslog = Syslog.open( File.basename($0), Syslog::LOG_NDELAY && Syslog::LOG_PERRO Symbiosis::Email::PoppassHandler.prefix = prefix Symbiosis::Email::PoppassHandler.syslog = syslog -# If we use systemd socket activation in future, here's how. -# -# SD_LISTEN_FDS_START = 3 -# -# if ENV['LISTEN_PID'].to_i == $$ -# # use existing socket passed from systemd -# systemd_socket = Socket.for_fd(SD_LISTEN_FDS_START + 0) -# syslog.info "Got socket #{SD_LISTEN_FDS_START + 0} from systemd" -# end - EventMachine.run do begin - EventMachine.start_server "127.0.0.1", port, Symbiosis::Email::PoppassHandler + SD_LISTEN_FDS_START = 3 + if ENV['LISTEN_PID'].to_i == $$ + #use existing socket passed from systemd + systemd_socket = Socket.for_fd(SD_LISTEN_FDS_START + 0) + EventMachine.attach_server(systemd_socket, Symbiosis::Email::PoppassHandler) + else + EventMachine.start_server "127.0.0.1", port, Symbiosis::Email::PoppassHandler + end rescue StandardError => err syslog.info "Caught #{err.to_s} " EM.stop end end - - -- GitLab