[+] 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
This commit is contained in:
Charles Le Maux 2024-09-10 13:13:31 +02:00
parent fe2ad4e0a1
commit 88eaf0b4d8

10
app.py
View File

@ -1,3 +1,4 @@
import argparse
import atexit import atexit
import http import http
import inspect import inspect
@ -185,8 +186,15 @@ def exit_safety() -> None:
app.register_blueprint(apiBP) app.register_blueprint(apiBP)
if __name__ == '__main__': 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) atexit.register(exit_safety)
scheduler = BackgroundScheduler() 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() scheduler.start()
app.run(host='0.0.0.0', port=3000, debug=False) app.run(host='0.0.0.0', port=3000, debug=False)