Skip to content

Commit

Permalink
Use systemd-notify on systems without python2 systemd bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
evverx committed Sep 11, 2015
1 parent b676e32 commit 134b3a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/salt-master.service
Expand Up @@ -5,6 +5,7 @@ After=syslog.target network.target
[Service]
LimitNOFILE=16384
Type=notify
NotifyAccess=all
ExecStart=/usr/bin/salt-master

[Install]
Expand Down
10 changes: 10 additions & 0 deletions salt/utils/process.py
Expand Up @@ -35,14 +35,24 @@
pass


def systemd_notify_call(action):
process = subprocess.Popen(['systemd-notify', action], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process.communicate()
status = process.poll()
return status == 0


def notify_systemd():
'''
Notify systemd that this process has started
'''
try:
import systemd.daemon
except ImportError:
if salt.utils.which('systemd-notify') and systemd_notify_call('--booted'):
return systemd_notify_call('--ready')
return False

if systemd.daemon.booted():
try:
return systemd.daemon.notify('READY=1')
Expand Down

0 comments on commit 134b3a6

Please sign in to comment.