mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 06:23:34 -07:00
bug: startup failure with no database
This commit is contained in:
parent
0989559ded
commit
0170aa3f03
4 changed files with 19 additions and 7 deletions
|
@ -15,11 +15,7 @@ from routes import (
|
|||
)
|
||||
from utils.api_docs import generate_api_docs
|
||||
from utils.logger import logger
|
||||
|
||||
# startup.pre_start()
|
||||
|
||||
# if USE_SQL:
|
||||
# sql_global_init()
|
||||
from utils.startup import post_start
|
||||
|
||||
app = FastAPI(
|
||||
title="Mealie",
|
||||
|
@ -57,6 +53,7 @@ def invalid_api():
|
|||
|
||||
app.include_router(static_routes.router)
|
||||
|
||||
# post_start()
|
||||
|
||||
# Generate API Documentation
|
||||
if not PRODUCTION:
|
||||
|
|
|
@ -2,8 +2,11 @@ from app_config import SQLITE_FILE, USE_MONGO, USE_SQL
|
|||
|
||||
from db.sql.db_session import globa_init as sql_global_init
|
||||
|
||||
sql_exists = SQLITE_FILE.is_file()
|
||||
|
||||
if USE_SQL:
|
||||
sql_global_init(SQLITE_FILE)
|
||||
|
||||
pass
|
||||
|
||||
elif USE_MONGO:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from typing import List, Optional
|
||||
|
||||
from db.database import db
|
||||
from db.db_setup import sql_exists
|
||||
from pydantic import BaseModel
|
||||
from utils.logger import logger
|
||||
|
||||
|
@ -120,7 +121,7 @@ def default_theme_init():
|
|||
|
||||
try:
|
||||
SiteTheme.get_by_name("default")
|
||||
return "default theme exists"
|
||||
logger.info("Default theme exists... skipping generation")
|
||||
except:
|
||||
logger.info("Generating Default Theme")
|
||||
colors = Colors(**default_colors)
|
||||
|
@ -128,4 +129,15 @@ def default_theme_init():
|
|||
default_theme.save_to_db()
|
||||
|
||||
|
||||
def default_settings_init():
|
||||
try:
|
||||
document = db.settings.get("main")
|
||||
except:
|
||||
webhooks = Webhooks()
|
||||
default_entry = SiteSettings(name="main", webhooks=webhooks)
|
||||
document = db.settings.save_new(default_entry.dict(), webhooks.dict())
|
||||
|
||||
|
||||
if not sql_exists:
|
||||
default_settings_init()
|
||||
default_theme_init
|
||||
|
|
|
@ -6,7 +6,7 @@ from services.settings_services import default_theme_init
|
|||
CWD = Path(__file__).parent
|
||||
|
||||
|
||||
def pre_start():
|
||||
def post_start():
|
||||
default_theme_init()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue