Phase 5 (D4): headless daemon entry point (ewsdrd)

ewsdrd.lpr — a console daemon that runs TRadioController + TWebAdapter WITHOUT
TMainForm/LCL, proving the Phase-5 goal: web-only headless operation. THeadlessHost
wires the data-path callbacks to the controller, the web command handlers to the
adapter (lifecycle ones marshalled to the main thread via FCtrl.Invoke =
TThread.Synchronize), opens WDSP synchronously, autostarts the saved device, and
runs a CheckSynchronize + periodic PushState loop. SIGINT/SIGTERM → graceful
StopAndDisconnect (persist + Run=0).

To keep the controller graph truly LCL-free, PlatformUtils now guards its only
Forms dependency (Screen.PixelsPerInch in CurrentScreenDPI) behind {$IFNDEF
HEADLESS}; the GUI build is byte-identical (HEADLESS undefined). build-ewsdrd.sh
compiles the headless graph from source with -Mobjfpc (nested comments) -dHEADLESS
into a separate lib-headless/ output dir, untouching the GUI .ppu.

Verified: builds clean; runs headless, web server up (HTTP 401 = serving), no LCL;
SIGINT shuts down gracefully. Radio-connect + web round-trip need hardware to test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Uladzimir Karpenka
2026-06-09 15:26:44 +03:00
co-authored by Claude Opus 4.8
parent b9c358789d
commit de234b56e5
4 changed files with 432 additions and 1 deletions
+5 -1
View File
@@ -22,7 +22,7 @@ function GetAppCfgDir: string;
implementation
uses
SysUtils, Forms;
SysUtils {$IFNDEF HEADLESS}, Forms{$ENDIF};
function QtPlatformAllowsOpenGLControls: Boolean;
var
@@ -62,8 +62,12 @@ end;
function CurrentScreenDPI: Integer;
begin
{$IFNDEF HEADLESS}
Result := Screen.PixelsPerInch;
if Result <= 0 then Result := 96;
{$ELSE}
Result := 96; // headless-демон без LCL: экрана нет, дефолт DPI
{$ENDIF}
end;
function GetAppCfgDir: string;