diff --git a/website/app.py b/website/app.py index 9702ee9..520adf0 100644 --- a/website/app.py +++ b/website/app.py @@ -4,6 +4,18 @@ from flask import render_template import os from app.utils.init_modules import create_modules_db +import signal +import sys +import subprocess + +def signal_handler(sig, frame): + path = os.path.join(os.getcwd(), "launch.sh") + req = [path, "-ks"] + subprocess.call(req) + sys.exit(0) + +signal.signal(signal.SIGINT, signal_handler) + parser = argparse.ArgumentParser() parser.add_argument("-i", "--init_db", help="Initialise the db if it not exist", action="store_true") diff --git a/website/launch.sh b/website/launch.sh index e065512..36ae41c 100755 --- a/website/launch.sh +++ b/website/launch.sh @@ -1,8 +1,18 @@ #!/bin/bash +isscripted=`screen -ls | egrep '[0-9]+.misp_mod' | cut -d. -f1` +function killscript { + if [ $isscripted ]; then + screen -X -S misp_mod quit + fi +} function launch { export FLASKENV="development" + killscript + screen -dmS "misp_mod" + screen -S "misp_mod" -X screen -t "misp_modules_server" bash -c "../env/bin/misp-modules -l 127.0.0.1; read x" + sleep 2 python3 app.py -m python3 app.py } @@ -30,6 +40,8 @@ if [ "$1" ]; then -r | --reload_db ) reload_db; ;; -t | --test ) test; + ;; + -ks | --killscript ) killscript; esac shift else