diff --git a/.avalon/gen.py b/.avalon/gen.py index 5748337..8bc4982 100644 --- a/.avalon/gen.py +++ b/.avalon/gen.py @@ -4,4 +4,4 @@ filesFolder = sys.argv[2] with open(binf, 'w') as f: - f.write(f'#!/bin/bash\ncd "{filesFolder}"\npython3 "{filesFolder}/main.py" "$@"') \ No newline at end of file + f.write(f'#!/bin/bash\ncd "{filesFolder}"\npython3 "{filesFolder}/villicus.py" "$@"') diff --git a/.avalon/package b/.avalon/package index ef34454..ef66774 100644 --- a/.avalon/package +++ b/.avalon/package @@ -1,7 +1,7 @@ { "author": "R2Boyo25", - "repo": "ProgMan", - "binname": "programman", + "repo": "Villicus", + "binname": "villicus", "installScript": ".avalon/gen.py", "mvBinAfterInstallScript": true, "toCopy": [ diff --git a/main.py b/villicus.py similarity index 97% rename from main.py rename to villicus.py index 5783755..ec99668 100644 --- a/main.py +++ b/villicus.py @@ -5,6 +5,7 @@ import subprocess import logging import click +import sys from fcntl import fcntl, F_GETFL, F_SETFL from os import O_NONBLOCK, read import signal @@ -127,7 +128,7 @@ def proc(self, name): def killall(self): for process in self.dct.items(): - process.kill() + process[1].kill() procs = Procs() @@ -349,6 +350,11 @@ def listProcs(): def procShow(proc): return render_template("proc.html", proc=proc, procdata=procs.proc(proc).dct, running=procs.proc(proc).running, paused=procs.proc(proc).paused, returncode=procs.proc(proc).returncode) +def cleanup_processes(signal, frame): + procs.killall() + sys.exit(0) + +signal.signal(signal.SIGINT, cleanup_processes) @app.route('/source/') def returnSourceFile(filename): @@ -356,9 +362,5 @@ def returnSourceFile(filename): if __name__ == '__main__': - try: - start() - app.run(host='0.0.0.0', port=4057) - - except KeyboardInterrupt: - procs.killall() + start() + app.run(host='0.0.0.0', port=4057)