From 22ba9ae76eaee5c4ff792e27881dbf165ec6f326 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Sat, 3 Dec 2016 16:48:07 +0100 Subject: merge_backup, merge_dist: Bring child processes down on TERM. --- tools/merge_backup.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tools/merge_backup.py') 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: -- cgit v1.1