fix(init): remove auto database initialization from module load
Database initialization should not run on every module load as it would risk data loss. Tables should be created/maintained separately.
This commit is contained in:
parent
b950930156
commit
e03d27edd9
@ -33,22 +33,6 @@ def load_hermes_web_cli():
|
||||
"""
|
||||
from ahserver.serverenv import ServerEnv
|
||||
|
||||
# Initialize database tables if needed
|
||||
try:
|
||||
from .init_db import init_database
|
||||
import asyncio
|
||||
# Run database initialization in a new event loop if needed
|
||||
try:
|
||||
asyncio.get_running_loop()
|
||||
# If we're already in an async context, create a task
|
||||
asyncio.create_task(init_database())
|
||||
except RuntimeError:
|
||||
# No running loop, run synchronously
|
||||
asyncio.run(init_database())
|
||||
except Exception as e:
|
||||
print(f"Warning: Database initialization failed: {str(e)}")
|
||||
# Continue loading even if DB init fails - functions will handle errors gracefully
|
||||
|
||||
# Get the ServerEnv instance
|
||||
env = ServerEnv()
|
||||
|
||||
@ -69,12 +53,10 @@ def load_hermes_web_cli():
|
||||
env.validate_service_url = validate_service_url
|
||||
env.generate_session_id = generate_session_id
|
||||
|
||||
# Also register the user context helper if needed
|
||||
|
||||
return True
|
||||
|
||||
# Database operations using sqlor-database-module
|
||||
async def get_all_services(userid: str) -> List[Dict]:
|
||||
async def get_all_services_old(userid: str) -> List[Dict]:
|
||||
"""Get all registered Hermes services for the current user from database."""
|
||||
try:
|
||||
# Query services table with user_id filter using sqlor-database-module
|
||||
@ -475,22 +457,6 @@ async def get_session_by_id(userid, session_id: str) -> Optional[Dict]:
|
||||
"""
|
||||
from ahserver.serverenv import ServerEnv
|
||||
|
||||
# Initialize database tables if needed
|
||||
try:
|
||||
from .init_db import init_database
|
||||
import asyncio
|
||||
# Run database initialization in a new event loop if needed
|
||||
try:
|
||||
asyncio.get_running_loop()
|
||||
# If we're already in an async context, create a task
|
||||
asyncio.create_task(init_database())
|
||||
except RuntimeError:
|
||||
# No running loop, run synchronously
|
||||
asyncio.run(init_database())
|
||||
except Exception as e:
|
||||
print(f"Warning: Database initialization failed: {str(e)}")
|
||||
# Continue loading even if DB init fails - functions will handle errors gracefully
|
||||
|
||||
# Get the ServerEnv instance
|
||||
env = ServerEnv()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user