diff options
Diffstat (limited to 'cts/support/pacemaker-cts-dummyd.in')
-rw-r--r-- | cts/support/pacemaker-cts-dummyd.in | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/cts/support/pacemaker-cts-dummyd.in b/cts/support/pacemaker-cts-dummyd.in new file mode 100644 index 0000000..453a644 --- /dev/null +++ b/cts/support/pacemaker-cts-dummyd.in @@ -0,0 +1,55 @@ +#!@PYTHON@ +""" Slow-starting idle daemon that notifies systemd when it starts +""" + +__copyright__ = "Copyright 2014-2020 the Pacemaker project contributors" +__license__ = "GNU General Public License version 2 or later (GPLv2+) WITHOUT ANY WARRANTY" + +import sys +import time +import signal +import subprocess +have_systemd_daemon = True +try: + import systemd.daemon +except ImportError: + have_systemd_daemon = False + +delay = None + +def parse_args(): + global delay + + # Lone argument is a number of seconds to delay start and stop + if len(sys.argv) > 0: + try: + delay = float(sys.argv[1]) + except ValueError: + delay = None + + +def twiddle(): + global delay + + if delay is not None: + time.sleep(delay) + + +def bye(signum, frame): + twiddle() + sys.exit(0) + + +if __name__ == "__main__": + + parse_args() + signal.signal(signal.SIGTERM, bye) + twiddle() + if have_systemd_daemon: + systemd.daemon.notify("READY=1") + else: + subprocess.call(["systemd-notify", "READY=1"]) + + # This isn't a "proper" daemon, but that would be overkill for testing purposes + while True: + time.sleep(600.0) |