diff --git a/mealie/core/config.py b/mealie/core/config.py index 3eb5c595..dd787447 100644 --- a/mealie/core/config.py +++ b/mealie/core/config.py @@ -151,6 +151,8 @@ class AppSettings(BaseSettings): DEFAULT_EMAIL: str = "changeme@email.com" DEFAULT_PASSWORD: str = "MyPassword" + SCHEDULER_DATABASE = f"sqlite:///{app_dirs.DATA_DIR.joinpath('scheduler.db')}" + TOKEN_TIME: int = 2 # Time in Hours # Not Used! diff --git a/mealie/routes/recipe/recipe_crud_routes.py b/mealie/routes/recipe/recipe_crud_routes.py index 34331e23..4e8046dd 100644 --- a/mealie/routes/recipe/recipe_crud_routes.py +++ b/mealie/routes/recipe/recipe_crud_routes.py @@ -1,5 +1,4 @@ import json -from mealie.routes.routers import UserAPIRouter import shutil from shutil import copyfileobj from zipfile import ZipFile @@ -11,6 +10,7 @@ from mealie.core.root_logger import get_logger from mealie.db.database import db from mealie.db.db_setup import generate_session from mealie.routes.deps import get_current_user, is_logged_in, temporary_zip_path +from mealie.routes.routers import UserAPIRouter from mealie.schema.recipe import Recipe, RecipeAsset, RecipeImageTypes, RecipeURLIn from mealie.schema.user import UserInDB from mealie.services.events import create_recipe_event @@ -185,16 +185,15 @@ def delete_recipe( try: recipe: Recipe = db.recipes.delete(session, recipe_slug) delete_assets(recipe_slug=recipe_slug) - background_tasks.add_task( - create_recipe_event, - "Recipe Deleted", - f"'{recipe.name}' deleted by {current_user.full_name}", - session=session, - ) - return recipe except Exception: raise HTTPException(status.HTTP_400_BAD_REQUEST) + background_tasks.add_task( + create_recipe_event, "Recipe Deleted", f"'{recipe.name}' deleted by {current_user.full_name}", session=session + ) + + return recipe + @user_router.put("/{recipe_slug}/image") def update_recipe_image( diff --git a/mealie/run.sh b/mealie/run.sh index 6f48ea3c..935c3836 100755 --- a/mealie/run.sh +++ b/mealie/run.sh @@ -54,5 +54,5 @@ else # Start API # uvicorn mealie.app:app --host 0.0.0.0 --port 9000 - gunicorn mealie.app:app -b 0.0.0.0:9000 -k uvicorn.workers.UvicornWorker -c /app/gunicorn_conf.py + gunicorn mealie.app:app -b 0.0.0.0:9000 -k uvicorn.workers.UvicornWorker -c /app/gunicorn_conf.py --preload fi diff --git a/mealie/services/scheduler/global_scheduler.py b/mealie/services/scheduler/global_scheduler.py index a01f0da6..56fbdc80 100644 --- a/mealie/services/scheduler/global_scheduler.py +++ b/mealie/services/scheduler/global_scheduler.py @@ -1,3 +1,5 @@ +from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore from apscheduler.schedulers.background import BackgroundScheduler +from mealie.core.config import settings -scheduler = BackgroundScheduler() +scheduler = BackgroundScheduler(jobstores={"default": SQLAlchemyJobStore(settings.SCHEDULER_DATABASE)})