Commit e6685e00 authored by segfault's avatar segfault

Add --debug option to pause execution for debugging in some error cases

parent 71916f3a
......@@ -22,6 +22,9 @@ SERVICES_PATH = BASE_PATH
MACHINE_DIR = "/var/lib/machines"
SYSTEMD_UNIT_DIR = "/lib/systemd/system"
# Indicates whether the current execution is for debugging purposes
DEBUG = False
# --- Translation stuff --- #
import gettext
......
......@@ -8,6 +8,7 @@ import subprocess
import sh
from onionkit import _
from onionkit import DEBUG
from onionkit import CONTAINER_BASE, MACHINE_DIR, SYSTEMD_UNIT_DIR
from typing import List
......@@ -293,5 +294,10 @@ class ContainerManager(object):
self.start()
try:
yield
except Exception as e:
if DEBUG:
logger.exception(e)
input("Paused to allow debugging. Press Enter to continue")
raise
finally:
self.stop()
......@@ -94,6 +94,7 @@ class TorManager(object):
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--verbose", "-v", action="count")
parser.add_argument("--debug", action="store_true", help="Pause the execution in some error cases to allow debugging")
parser.add_argument("--log-file", "-l")
return parser.parse_args()
......@@ -101,6 +102,8 @@ def parse_args():
def main():
args = parse_args()
onionkit.logger.initialize(args.verbose, args.log_file)
if args.debug:
onionkit.DEBUG = True
OnionKit().register()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment