mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
[+] New API cleanup system
This commit is contained in:
parent
21fb9f1286
commit
362a079c69
11
app.py
11
app.py
@ -1,5 +1,4 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import atexit
|
|
||||||
import http
|
import http
|
||||||
import inspect
|
import inspect
|
||||||
import os
|
import os
|
||||||
@ -9,6 +8,7 @@ from apscheduler.schedulers.background import BackgroundScheduler
|
|||||||
from firebase_admin.auth import UserNotFoundError, UserRecord
|
from firebase_admin.auth import UserNotFoundError, UserRecord
|
||||||
from flask import (Blueprint, Flask, Response, jsonify, request)
|
from flask import (Blueprint, Flask, Response, jsonify, request)
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
|
from werkzeug import run_simple
|
||||||
from werkzeug.datastructures import ImmutableMultiDict, FileStorage
|
from werkzeug.datastructures import ImmutableMultiDict, FileStorage
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
|
|
||||||
@ -179,22 +179,21 @@ def upload():
|
|||||||
return generic_response_maker(http.HTTPStatus.OK, "Successfully uploaded files !")
|
return generic_response_maker(http.HTTPStatus.OK, "Successfully uploaded files !")
|
||||||
|
|
||||||
|
|
||||||
def exit_safety() -> None:
|
def api_cleanup() -> None:
|
||||||
firebase_manager.set_servers_not_running()
|
firebase_manager.set_servers_not_running()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
app.register_blueprint(apiBP)
|
app.register_blueprint(apiBP)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Background Scheduler")
|
parser = argparse.ArgumentParser(description="Background Scheduler")
|
||||||
parser.add_argument('--interval', type=int, default=10, help="Interval in minutes")
|
parser.add_argument('--interval', type=int, default=10, help="Interval in minutes")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
atexit.register(exit_safety)
|
|
||||||
|
|
||||||
scheduler = BackgroundScheduler()
|
scheduler = BackgroundScheduler()
|
||||||
scheduler.add_job(generic_executor.scheduled_actions, 'interval', minutes=args.interval)
|
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)
|
run_simple('0.0.0.0', 3000, app, use_debugger=False, use_reloader=False)
|
||||||
|
api_cleanup()
|
Loading…
Reference in New Issue
Block a user