#!@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)