diff --git a/deployment/windows/scripts/Fix-BackendPythonPath.ps1 b/deployment/windows/scripts/Fix-BackendPythonPath.ps1 new file mode 100644 index 0000000..b4cd46b --- /dev/null +++ b/deployment/windows/scripts/Fix-BackendPythonPath.ps1 @@ -0,0 +1,31 @@ +# Quick fix script to update Backend service PYTHONPATH +# Run this as Administrator to fix the ModuleNotFoundError + +param( + [string]$InstallPath = "C:\inetpub\wwwroot\roa2web", + [string]$ServiceName = "ROA2WEB-Backend" +) + +Write-Host "Fixing Backend service PYTHONPATH..." -ForegroundColor Cyan + +# Stop service +Write-Host "Stopping service..." -ForegroundColor Yellow +& nssm stop $ServiceName +Start-Sleep -Seconds 3 + +# Update PYTHONPATH to shared directory +$sharedPath = Join-Path $InstallPath "shared" +Write-Host "Setting PYTHONPATH to: $sharedPath" -ForegroundColor Yellow +& nssm set $ServiceName AppEnvironmentExtra "PYTHONPATH=$sharedPath" + +# Start service +Write-Host "Starting service..." -ForegroundColor Yellow +& nssm start $ServiceName +Start-Sleep -Seconds 3 + +# Check status +Write-Host "`nChecking service status..." -ForegroundColor Cyan +& nssm status $ServiceName + +Write-Host "`nDone! Check logs at: $InstallPath\logs\backend-stderr.log" -ForegroundColor Green +Write-Host "If errors persist, check the log file for details." -ForegroundColor Yellow diff --git a/deployment/windows/scripts/ROA2WEB-Console.ps1 b/deployment/windows/scripts/ROA2WEB-Console.ps1 index db7b113..a1e018e 100644 --- a/deployment/windows/scripts/ROA2WEB-Console.ps1 +++ b/deployment/windows/scripts/ROA2WEB-Console.ps1 @@ -624,7 +624,10 @@ function Install-BackendFirstTime { & nssm set $Config.BackendServiceName Description $Config.BackendServiceDescription & nssm set $Config.BackendServiceName Start SERVICE_AUTO_START & nssm set $Config.BackendServiceName AppDirectory $Config.BackendPath - & nssm set $Config.BackendServiceName AppEnvironmentExtra "PYTHONPATH=$($Config.InstallPath)" + + # Set PYTHONPATH to shared directory for module imports + $sharedPath = Join-Path $Config.InstallPath "shared" + & nssm set $Config.BackendServiceName AppEnvironmentExtra "PYTHONPATH=$sharedPath" # Set logging $stdoutLog = Join-Path $Config.LogsPath "backend-stdout.log"