mirror of
https://git.mirrors.martin98.com/https://github.com/open-webui/open-webui
synced 2025-08-18 03:45:56 +08:00
fix: RESET_CONFIG_ON_START not working
This commit is contained in:
parent
1767b64135
commit
92b1acd6fb
@ -87,6 +87,12 @@ def save_to_db(data):
|
|||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
def reset_config():
|
||||||
|
with get_db() as db:
|
||||||
|
db.query(Config).delete()
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
|
||||||
# When initializing, check if config.json exists and migrate it to the database
|
# When initializing, check if config.json exists and migrate it to the database
|
||||||
if os.path.exists(f"{DATA_DIR}/config.json"):
|
if os.path.exists(f"{DATA_DIR}/config.json"):
|
||||||
data = load_json_config()
|
data = load_json_config()
|
||||||
|
@ -234,18 +234,6 @@ if FROM_INIT_PY:
|
|||||||
).resolve()
|
).resolve()
|
||||||
|
|
||||||
|
|
||||||
RESET_CONFIG_ON_START = (
|
|
||||||
os.environ.get("RESET_CONFIG_ON_START", "False").lower() == "true"
|
|
||||||
)
|
|
||||||
|
|
||||||
if RESET_CONFIG_ON_START:
|
|
||||||
try:
|
|
||||||
os.remove(f"{DATA_DIR}/config.json")
|
|
||||||
with open(f"{DATA_DIR}/config.json", "w") as f:
|
|
||||||
f.write("{}")
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# Database
|
# Database
|
||||||
####################################
|
####################################
|
||||||
@ -265,6 +253,10 @@ if "postgres://" in DATABASE_URL:
|
|||||||
DATABASE_URL = DATABASE_URL.replace("postgres://", "postgresql://")
|
DATABASE_URL = DATABASE_URL.replace("postgres://", "postgresql://")
|
||||||
|
|
||||||
|
|
||||||
|
RESET_CONFIG_ON_START = (
|
||||||
|
os.environ.get("RESET_CONFIG_ON_START", "False").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# WEBUI_AUTH (Required for security)
|
# WEBUI_AUTH (Required for security)
|
||||||
####################################
|
####################################
|
||||||
|
@ -79,6 +79,7 @@ from open_webui.config import (
|
|||||||
WEBUI_NAME,
|
WEBUI_NAME,
|
||||||
AppConfig,
|
AppConfig,
|
||||||
run_migrations,
|
run_migrations,
|
||||||
|
reset_config,
|
||||||
)
|
)
|
||||||
from open_webui.constants import ERROR_MESSAGES, TASKS, WEBHOOK_MESSAGES
|
from open_webui.constants import ERROR_MESSAGES, TASKS, WEBHOOK_MESSAGES
|
||||||
from open_webui.env import (
|
from open_webui.env import (
|
||||||
@ -92,6 +93,7 @@ from open_webui.env import (
|
|||||||
WEBUI_SESSION_COOKIE_SAME_SITE,
|
WEBUI_SESSION_COOKIE_SAME_SITE,
|
||||||
WEBUI_SESSION_COOKIE_SECURE,
|
WEBUI_SESSION_COOKIE_SECURE,
|
||||||
WEBUI_URL,
|
WEBUI_URL,
|
||||||
|
RESET_CONFIG_ON_START,
|
||||||
)
|
)
|
||||||
from fastapi import (
|
from fastapi import (
|
||||||
Depends,
|
Depends,
|
||||||
@ -187,6 +189,9 @@ https://github.com/open-webui/open-webui
|
|||||||
async def lifespan(app: FastAPI):
|
async def lifespan(app: FastAPI):
|
||||||
run_migrations()
|
run_migrations()
|
||||||
|
|
||||||
|
if RESET_CONFIG_ON_START:
|
||||||
|
reset_config()
|
||||||
|
|
||||||
asyncio.create_task(periodic_usage_pool_cleanup())
|
asyncio.create_task(periodic_usage_pool_cleanup())
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user