diff options
-rwxr-xr-x | tools/merge_backup.py | 8 | ||||
-rwxr-xr-x | tools/merge_dist.py | 9 |
2 files changed, 15 insertions, 2 deletions
diff --git a/tools/merge_backup.py b/tools/merge_backup.py index 8a44c65..c0e7001 100755 --- a/tools/merge_backup.py +++ b/tools/merge_backup.py @@ -12,6 +12,7 @@ import select import requests import errno import logging +import signal from time import sleep from base64 import b64encode, b64decode from os import stat @@ -22,7 +23,7 @@ from mergetools import chunks, backup_sendlog, get_logorder, \ get_verifiedsize, get_missingentriesforbackup, \ hexencode, setverifiedsize, sendentries_merge, verifyroot, \ get_nfetched, parse_args, perm, waitforfile, flock_ex_or_fail, \ - Status, loginit, start_worker + Status, loginit, start_worker, terminate_child_procs def backup_loop(nodename, nodeaddress, own_key, paths, verifiedsize, chunk): for trynumber in range(5, 0, -1): @@ -201,6 +202,10 @@ def merge_backup(args, config, localconfig, secondaries): return failures +def term(signal, arg): + terminate_child_procs() + sys.exit(1) + def main(): """ Wait until 'fetched' exists and read it. @@ -235,6 +240,7 @@ def main(): else: nodes = [n for n in all_secondaries if n["name"] in args.node] + signal.signal(signal.SIGTERM, term) create_ssl_context(cafile=paths["https_cacertfile"]) fetched_statinfo = waitforfile(fetched_path) while True: diff --git a/tools/merge_dist.py b/tools/merge_dist.py index f1bdaf9..aa793e6 100755 --- a/tools/merge_dist.py +++ b/tools/merge_dist.py @@ -11,6 +11,7 @@ import sys import json import requests import logging +import signal from time import sleep from base64 import b64encode, b64decode from os import stat @@ -19,7 +20,8 @@ from certtools import timing_point, create_ssl_context from mergetools import get_curpos, get_logorder, chunks, get_missingentries, \ publish_sth, sendlog, sendentries, parse_args, perm, \ get_frontend_verifiedsize, frontend_verify_entries, \ - waitforfile, flock_ex_or_fail, Status, loginit, start_worker + waitforfile, flock_ex_or_fail, Status, loginit, start_worker, \ + terminate_child_procs def sendlog_helper(entries, curpos, nodename, nodeaddress, own_key, paths, statusupdates): @@ -207,6 +209,10 @@ def merge_dist_parallel(args, localconfig, frontendnodes, chainsdb, s): return -1 +def term(signal, arg): + terminate_child_procs() + sys.exit(1) + def main(): """ Distribute missing entries and the STH to all frontend nodes, in @@ -231,6 +237,7 @@ def main(): statusfile = mergedb + "/merge_dist.status" s = Status(statusfile) + signal.signal(signal.SIGTERM, term) create_ssl_context(cafile=paths["https_cacertfile"]) if len(args.node) == 0: |