initialization as fastcgi event
This commit is contained in:
parent
2341849e54
commit
15376a1052
2 changed files with 8 additions and 2 deletions
|
@ -60,6 +60,7 @@ class DateTimeAction(Action):
|
||||||
raise ValueError("'%s' is not a valid datetime" % values)
|
raise ValueError("'%s' is not a valid datetime" % values)
|
||||||
setattr(namespace, self.dest, parsed_val)
|
setattr(namespace, self.dest, parsed_val)
|
||||||
|
|
||||||
|
code_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
def common_pre():
|
def common_pre():
|
||||||
prechecks = [pre_check_user, pre_check_permissions, pre_check_ffmpeg]
|
prechecks = [pre_check_user, pre_check_permissions, pre_check_ffmpeg]
|
||||||
|
@ -76,7 +77,7 @@ def common_pre():
|
||||||
if getattr(sys, "frozen", False):
|
if getattr(sys, "frozen", False):
|
||||||
os.chdir(sys._MEIPASS)
|
os.chdir(sys._MEIPASS)
|
||||||
else:
|
else:
|
||||||
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
os.chdir(code_dir)
|
||||||
for conf in configs:
|
for conf in configs:
|
||||||
get_config().from_pyfile(conf)
|
get_config().from_pyfile(conf)
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ logger = logging.getLogger("server")
|
||||||
|
|
||||||
common_pre()
|
common_pre()
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
db = RecDB(get_config()["DB_URI"])
|
db = None
|
||||||
|
|
||||||
|
|
||||||
def date_read(s):
|
def date_read(s):
|
||||||
|
@ -38,6 +38,11 @@ def rec_sanitize(rec):
|
||||||
d["endtime"] = date_write(d["endtime"])
|
d["endtime"] = date_write(d["endtime"])
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
@app.on_event("startup")
|
||||||
|
async def startup_event():
|
||||||
|
global db
|
||||||
|
common_pre()
|
||||||
|
db = RecDB(get_config()["DB_URI"])
|
||||||
|
|
||||||
@app.get("/date/date")
|
@app.get("/date/date")
|
||||||
def date():
|
def date():
|
||||||
|
|
Loading…
Reference in a new issue