fix(knowledge-base): 优化知识库页面,重构后端job队列
This commit is contained in:
1 parent
7e4a2037d8
commit
b476b58a91
38 files changed
+992
-428
No files matched your search
+28
-2
@@ -2,7 +2,8 @@ param(
|
||||
[ValidateSet("sqlite", "postgres")]
|
||||
[string]$DbMode = "sqlite",
|
||||
[string]$DatabaseUrl = "",
|
||||
[switch]$SkipInstall
|
||||
[switch]$SkipInstall,
|
||||
[switch]$SkipWorker
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
@@ -132,6 +133,23 @@ function Start-BackendWindow {
|
||||
Start-Process powershell -ArgumentList @("-NoExit", "-ExecutionPolicy", "Bypass", "-Command", $cmd) | Out-Null
|
||||
}
|
||||
|
||||
function Start-KbWorkerWindow {
|
||||
param(
|
||||
[string]$BackendPath,
|
||||
[string]$Mode,
|
||||
[string]$DbUrl
|
||||
)
|
||||
|
||||
$dbExport = ""
|
||||
if ($Mode -eq "postgres" -and -not [string]::IsNullOrWhiteSpace($DbUrl)) {
|
||||
$escaped = $DbUrl.Replace("'", "''")
|
||||
$dbExport = "`$env:DATABASE_URL='$escaped'; "
|
||||
}
|
||||
|
||||
$cmd = "$dbExport Set-Location '$BackendPath'; .\venv\Scripts\python.exe .\worker_kb.py"
|
||||
Start-Process powershell -ArgumentList @("-NoExit", "-ExecutionPolicy", "Bypass", "-Command", $cmd) | Out-Null
|
||||
}
|
||||
|
||||
function Start-FrontendWindow {
|
||||
param([string]$FrontendPath)
|
||||
$cmd = "Set-Location '$FrontendPath'; npm run dev"
|
||||
@@ -155,9 +173,17 @@ Ensure-Backend -BackendPath $backendDir -PyCmd $pythonCmd -Mode $DbMode -DbUrl $
|
||||
Ensure-Frontend -FrontendPath $frontendDir -DoInstall $doInstall
|
||||
|
||||
Start-BackendWindow -BackendPath $backendDir -Mode $DbMode -DbUrl $DatabaseUrl
|
||||
if (-not $SkipWorker.IsPresent) {
|
||||
Start-KbWorkerWindow -BackendPath $backendDir -Mode $DbMode -DbUrl $DatabaseUrl
|
||||
}
|
||||
Start-FrontendWindow -FrontendPath $frontendDir
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Started in two new PowerShell windows." -ForegroundColor Green
|
||||
if ($SkipWorker.IsPresent) {
|
||||
Write-Host "Started in two new PowerShell windows." -ForegroundColor Green
|
||||
}
|
||||
else {
|
||||
Write-Host "Started in three new PowerShell windows." -ForegroundColor Green
|
||||
}
|
||||
Write-Host "Frontend URL: http://127.0.0.1:8881" -ForegroundColor Green
|
||||
Write-Host "Default local admin (sqlite/init scripts): admin / Hxit@54321" -ForegroundColor Green
|
||||
Reference in new issue
Block a user