From a57418b67bd03fe600745996d008a92c425ca13f Mon Sep 17 00:00:00 2001 From: kthoden Date: Wed, 14 Jul 2021 20:06:52 +0200 Subject: [PATCH] Add restart script --- scripts/restart.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 scripts/restart.py diff --git a/scripts/restart.py b/scripts/restart.py new file mode 100755 index 0000000..921dcbe --- /dev/null +++ b/scripts/restart.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 + +from utils.settings import BASE_DIR, load_config +from utils.functions import run + +import subprocess +import shlex +import os +from time import sleep + + +def stop( env ): + # run application + subprocess.call( + "docker-compose down", + shell=True, + env=env + ) + +if __name__ == '__main__': + + from argparse import ArgumentParser + + config = load_config() + + parser = ArgumentParser( + description="restart the webserver" + ) + parser.add_argument( + "--build", + action = "store_true" + ) + parser.add_argument( + "CMD", + nargs="*" + ) + + args = parser.parse_args() + + stop( config ) + + + CMD= \ + (vars(args)['CMD']) + run( + env=config, + build = args.build, + cmd=CMD + ) + + print("\n------------------------------\n") + print("You can view the tail of container log output with 'docker-compose logs -f' (ctrl + c to stop).")