Fix Backend service PYTHONPATH for shared module imports

Fixed critical runtime error where backend service couldn't import
shared modules (ModuleNotFoundError: No module named 'database').

Changes:
- Updated Install-BackendFirstTime: Set PYTHONPATH to shared directory
  instead of parent directory
- Added Fix-BackendPythonPath.ps1: Quick fix script for existing
  installations

The backend imports 'from database.oracle_pool' which requires the
database module to be in PYTHONPATH. Previously PYTHONPATH pointed to
C:\inetpub\wwwroot\roa2web but the database module is located at
C:\inetpub\wwwroot\roa2web\shared\database. Now PYTHONPATH correctly
points to the shared directory.

For existing installations, run Fix-BackendPythonPath.ps1 as Administrator
to update the service configuration without reinstalling.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-12 02:46:02 +02:00
parent 3adcb8f7b0
commit 914ab0107e
2 changed files with 35 additions and 1 deletions

View File

@@ -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"