diff options
author | Linus Nordberg <linus@nordu.net> | 2016-12-03 16:48:07 +0100 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2016-12-03 16:48:07 +0100 |
commit | 22ba9ae76eaee5c4ff792e27881dbf165ec6f326 (patch) | |
tree | 1aeacc3e666da609c0eabdbf46f70287612406c4 /tools/merge_backup.py | |
parent | 1befdbb267f9c0960b9049cb551b470dbac15ae1 (diff) |
merge_backup, merge_dist: Bring child processes down on TERM.
Diffstat (limited to 'tools/merge_backup.py')
-rwxr-xr-x | tools/merge_backup.py | 8 |
1 files changed, 7 insertions, 1 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: |