Skip to content

Commit 4369c8c

Browse files
authored
Refactor daemon initialization and logging process
1 parent e3b9671 commit 4369c8c

1 file changed

Lines changed: 49 additions & 37 deletions

File tree

.github/workflows/windows-concurrency-test.yml

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -61,54 +61,66 @@ jobs:
6161
shell: pwsh
6262
run: |
6363
Write-Host "=================================================="
64-
Write-Host "1. Spawning daemon in isolated background process..."
64+
Write-Host "1. Spawning daemon and waiting for 'Ready' signal..."
6565
Write-Host "=================================================="
66-
# We use -PassThru to ensure we trigger the process start effectively
67-
$proc = Start-Process -FilePath "8pkg" -ArgumentList "daemon", "start" -WindowStyle Hidden -PassThru
6866
69-
Write-Host "Waiting 12 seconds for daemon to fully initialize..."
70-
Start-Sleep -Seconds 12
67+
$tempDir = "$env:TEMP\omnipkg"
68+
if (!(Test-Path $tempDir)) { New-Item -ItemType Directory -Path $tempDir -Force }
7169
72-
Write-Host "`n=================================================="
73-
Write-Host "2. Checking Network / Socket bindings (TCP 5678)..."
74-
Write-Host "=================================================="
75-
# This proves if the C/Rust layer actually opened the port
76-
netstat -ano | findstr ":5678"
70+
$launcherLog = "$tempDir\daemon_launcher_stdout.log"
71+
# Clear old logs if they exist
72+
if (Test-Path $launcherLog) { Remove-Item $launcherLog }
73+
74+
# Launch the daemon in the background
75+
Start-Process cmd -ArgumentList "/c set OMNIPKG_DEBUG=1 && 8pkg daemon start > $launcherLog 2>&1" -WindowStyle Hidden
7776
77+
Write-Host "⏳ Daemon is initializing (Grounding config/KB)..."
78+
Write-Host "I will poll the socket every 2 seconds. Timeout: 180s."
79+
80+
$timeout = 180
81+
$elapsed = 0
82+
$daemonReady = $false
83+
84+
while ($elapsed -lt $timeout) {
85+
# 1. Check if port 5678 is open
86+
$socket = netstat -ano | findstr ":5678"
87+
if ($socket) {
88+
Write-Host "`n✅ Socket 5678 detected! Daemon is alive."
89+
$daemonReady = $true
90+
break
91+
}
92+
93+
# 2. Tail the launcher log so we can see the "Grounding" progress
94+
if (Test-Path $launcherLog) {
95+
$lastLine = Get-Content $launcherLog -Tail 1
96+
if ($lastLine) {
97+
Write-Host "`r[Launcher]: $lastLine" -NoNewline
98+
}
99+
}
100+
101+
Start-Sleep -Seconds 2
102+
$elapsed += 2
103+
}
104+
105+
if (-not $daemonReady) {
106+
Write-Host "`n❌ TIMEOUT: Daemon failed to start within 180s."
107+
Write-Host "--- FINAL LAUNCHER LOG ---"
108+
if (Test-Path $launcherLog) { Get-Content $launcherLog }
109+
exit 1
110+
}
111+
78112
Write-Host "`n=================================================="
79-
Write-Host "3. Testing Python Connection & Registry Discovery..."
113+
Write-Host "2. Final Verification"
80114
Write-Host "=================================================="
81115
python -c "
82-
import os, sys, json
116+
import json
83117
try:
84-
from omnipkg.isolation.worker_daemon import DaemonClient, DAEMON_LOG_FILE
85-
client = DaemonClient()
86-
status = client.status()
87-
print(f'✅ DAEMON RESPONDED: {json.dumps(status, indent=2)}')
88-
print(f'DAEMON_LOG_FILE CONSTANT: {DAEMON_LOG_FILE}')
118+
from omnipkg.isolation.worker_daemon import DaemonClient
119+
print(f'✅ Connection Test: {json.dumps(DaemonClient().status())}')
89120
except Exception as e:
90-
print(f'❌ DAEMON CONNECTION FAILED: {e}')
121+
print(f'❌ Connection Test Failed: {e}')
91122
"
92123
93-
Write-Host "`n=================================================="
94-
Write-Host "4. Finding and Dumping ALL daemon logs in TEMP..."
95-
Write-Host "=================================================="
96-
# The logs wandering into subfolders is a major clue. This finds them all.
97-
$logFiles = Get-ChildItem -Path "$env:TEMP\omnipkg" -Filter "omnipkg_daemon.log" -Recurse -ErrorAction SilentlyContinue
98-
99-
if ($logFiles.Count -eq 0) {
100-
Write-Host "❌ Could not find omnipkg_daemon.log anywhere in $env:TEMP\omnipkg"
101-
Write-Host "Full directory structure of TEMP\omnipkg:"
102-
Get-ChildItem -Path "$env:TEMP\omnipkg" -Recurse | Select-Object FullName
103-
} else {
104-
foreach ($file in $logFiles) {
105-
Write-Host "`n--- START OF LOG: $($file.FullName) ---"
106-
Get-Content $file.FullName
107-
Write-Host "--- END OF LOG ---"
108-
}
109-
}
110-
Write-Host "`n✅ Pre-start diagnostics complete."
111-
112124
- name: Run Demo (Option 8 - Quantum Multiverse)
113125
shell: cmd
114126
run: omnipkg demo 8 --non-interactive

0 commit comments

Comments
 (0)