mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
[+] 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:
parent
fe2ad4e0a1
commit
88eaf0b4d8
10
app.py
10
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)
|
||||
|
Loading…
Reference in New Issue
Block a user