allow wrapper to work as a daemon-restarter...

This commit is contained in:
Fredrik Eriksson 2023-08-03 16:35:58 +02:00
parent f56efb0085
commit 74201e59d6
Signed by: feffe
GPG Key ID: CD5A131FADFA3968

View File

@ -47,6 +47,10 @@ def parse_args():
'-L', '--no-lock', '-L', '--no-lock',
help='Allow multiple simultanious executions of this cron job', help='Allow multiple simultanious executions of this cron job',
action='store_true') action='store_true')
parser.add_argument(
'-r', '--restart',
help='Restart the process if not running; exit with success if previous instance is running',
action='store_true')
parser.add_argument( parser.add_argument(
@ -189,6 +193,8 @@ def main():
has_lock = aquire_lock(lckfile) has_lock = aquire_lock(lckfile)
if has_lock: if has_lock:
res = exec_command(args, o, e, r) res = exec_command(args, o, e, r)
elif args.restart:
res = 0
else: else:
e.write("CRONWRAPPER: Unable to aquire lock, previous instance still running?\n") e.write("CRONWRAPPER: Unable to aquire lock, previous instance still running?\n")
r.write("\nFalse\n") r.write("\nFalse\n")