From 88eaf0b4d856f6da76750c38e41b747f1b839ecc Mon Sep 17 00:00:00 2001 From: Charles Le Maux Date: Tue, 10 Sep 2024 13:13:31 +0200 Subject: [PATCH] [+] Added interval parameter for easier scheduler management. Scheduler will default to 10 minutes, meaning a server will take 20 to automatically close. The input interval shouldn't be lower than 5 minutes except when high load expected --- app.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 1c97743..9335448 100644 --- a/app.py +++ b/app.py @@ -1,3 +1,4 @@ +import argparse import atexit import http import inspect @@ -185,8 +186,15 @@ def exit_safety() -> None: app.register_blueprint(apiBP) if __name__ == '__main__': + + parser = argparse.ArgumentParser(description="Background Scheduler") + parser.add_argument('--interval', type=int, default=10, help="Interval in minutes") + args = parser.parse_args() + atexit.register(exit_safety) + scheduler = BackgroundScheduler() - scheduler.add_job(generic_executor.scheduled_actions, 'interval', minutes=10) + scheduler.add_job(generic_executor.scheduled_actions, 'interval', minutes=args.interval) scheduler.start() + app.run(host='0.0.0.0', port=3000, debug=False)