Skip to content

Commit

Permalink
Merge pull request #16 from Snawoot/notify
Browse files Browse the repository at this point in the history
systemd notify support
  • Loading branch information
Snawoot authored Mar 30, 2019
2 parents e2080fe + d5663e2 commit 1379cad
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion contrib/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ Description=Postfix MTA STS daemon instance
After=syslog.target network.target

[Service]
Type=simple
Type=notify
User=mta-sts
Group=mta-sts
# This is the ExecStart path for RHEL7 using python 36 from the Software collections.
# You may use a different python interpreter on other distributions
ExecStart=/opt/rh/rh-python36/root/bin/mta-sts-daemon
Restart=always
KillMode=process
TimeoutStartSec=10
TimeoutStopSec=30

[Install]
Expand Down
2 changes: 0 additions & 2 deletions contrib/postfix-mta-sts.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/systemctl start [email protected]
ExecReload=/bin/systemctl start [email protected] ; \
/bin/sleep 3 ; \
/bin/systemctl restart [email protected] ; \
/bin/sleep 3 ; \
/bin/systemctl stop [email protected]
ExecStop=/bin/systemctl stop [email protected]

Expand Down
4 changes: 4 additions & 0 deletions postfix_mta_sts_resolver/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import signal
from functools import partial

from sdnotify import SystemdNotifier
from . import utils
from . import defaults
from .responder import STSSocketmapResponder
Expand Down Expand Up @@ -66,8 +67,11 @@ async def amain(cfg, loop):
sig_handler = partial(exit_handler, exit_event)
signal.signal(signal.SIGTERM, sig_handler)
signal.signal(signal.SIGINT, sig_handler)
notifier = await loop.run_in_executor(None, SystemdNotifier)
await loop.run_in_executor(None, notifier.notify, "READY=1")
await exit_event.wait()
logger.debug("Eventloop interrupted. Shutting down server...")
await loop.run_in_executor(None, notifier.notify, "STOPPING=1")
beat.cancel()
await responder.stop()

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
'PyYAML>=3.12',
'aiosqlite>=0.9.0',
'aioredis>=1.2.0',
'sdnotify>=0.3.2',
],
entry_points={
'console_scripts': [
Expand Down

0 comments on commit 1379cad

Please sign in to comment.