fix(critical): auto-install + activate discovered plugins in prestart.sh
New plugins (self_improvement, knowledge) were discovered but never activated in the production DB. prestart.sh now auto-installs and activates all discovered builtin plugins on every container start.
This commit is contained in:
+31
@@ -107,6 +107,37 @@ python3 /app/scripts/sync_plugin_schema.py
|
||||
echo "[prestart] Seeding admin user if not exists..."
|
||||
python3 /app/scripts/seed_admin.py || echo "[prestart] WARNING: Admin seed failed (may already exist)"
|
||||
|
||||
echo "[prestart] Auto-installing and activating discovered plugins..."
|
||||
python3 -c "
|
||||
import asyncio
|
||||
from app.plugins.registry import get_registry
|
||||
from app.core.db import async_session_factory
|
||||
from sqlalchemy import select
|
||||
from app.models.plugin import Plugin as PluginModel
|
||||
|
||||
async def auto_activate_plugins():
|
||||
r = get_registry()
|
||||
discovered = r.discover_builtins()
|
||||
async with async_session_factory() as db:
|
||||
for name in discovered:
|
||||
result = await db.execute(select(PluginModel).where(PluginModel.name == name))
|
||||
record = result.scalar_one_or_none()
|
||||
try:
|
||||
if record is None:
|
||||
await r.install(db, name)
|
||||
await r.activate(db, name)
|
||||
print(f'[prestart] Installed + activated plugin: {name}')
|
||||
elif not record.active:
|
||||
await r.activate(db, name)
|
||||
print(f'[prestart] Activated plugin: {name}')
|
||||
except Exception as e:
|
||||
print(f'[prestart] WARNING: Could not activate plugin {name}: {e}')
|
||||
await db.commit()
|
||||
print('[prestart] Plugin auto-activation complete.')
|
||||
|
||||
asyncio.run(auto_activate_plugins())
|
||||
" || echo "[prestart] WARNING: Plugin auto-activation failed"
|
||||
|
||||
echo "[prestart] Starting uvicorn on 0.0.0.0:8000 (workers=1)..."
|
||||
exec uvicorn app.main:app \
|
||||
--host 0.0.0.0 \
|
||||
|
||||
Reference in New Issue
Block a user