Browse Source

Passing the Unix SIGTERM signal through to child processes like Borg.

master
Dan 1 year ago
parent
commit
27a6745743
4 changed files with 24 additions and 1 deletions
  1. 4
    0
      NEWS
  2. 2
    0
      borgmatic/commands/borgmatic.py
  3. 17
    0
      borgmatic/signals.py
  4. 1
    1
      setup.py

+ 4
- 0
NEWS View File

@@ -1,3 +1,7 @@
1.1.10.dev0
* Passing the Unix SIGTERM signal through to child processes like Borg. This means that Borg now
properly shuts down if borgmatic is terminated (e.g. due to a system suspend).

1.1.9
* #16, #38: Support for user-defined hooks before/after backup, or on error.
* #33: Improve clarity of logging spew at high verbosity levels.

+ 2
- 0
borgmatic/commands/borgmatic.py View File

@@ -8,6 +8,7 @@ import sys
from borgmatic.borg import check, create, prune
from borgmatic.commands import hook
from borgmatic.config import collect, convert, validate
from borgmatic.signals import configure_signals
from borgmatic.verbosity import VERBOSITY_SOME, VERBOSITY_LOTS, verbosity_to_log_level


@@ -120,6 +121,7 @@ def run_configuration(config_filename, args): # pragma: no cover

def main(): # pragma: no cover
try:
configure_signals()
args = parse_arguments(*sys.argv[1:])
logging.basicConfig(level=verbosity_to_log_level(args.verbosity), format='%(message)s')


+ 17
- 0
borgmatic/signals.py View File

@@ -0,0 +1,17 @@
import os
import signal


def _handle_signal(signal_number, frame):
'''
Send the signal to all processes in borgmatic's process group, which includes child process.
'''
os.killpg(os.getpgrp(), signal_number)


def configure_signals():
'''
Configure borgmatic's signal handlers to pass relevant signals through to any child processes
like Borg.
'''
signal.signal(signal.SIGTERM, _handle_signal)

+ 1
- 1
setup.py View File

@@ -1,7 +1,7 @@
from setuptools import setup, find_packages


VERSION = '1.1.9'
VERSION = '1.1.10.dev0'


setup(

Loading…
Cancel
Save