forked from unom/punktfunk
fix(windows/web): start the console once its inputs exist, and verify it started
A fresh install left PunktfunkWeb registered but not running: `web setup` waited only for the mgmt token before firing `schtasks /run`, while `web-run.cmd` also requires the host identity cert — and the host writes the token during argument parsing but `cert.pem` only after the pure-Rust RSA-2048 keygen inside `serve`. The launcher lost that race, exited 1, and since the task carried no trigger but boot (Task Scheduler does not reliably restart on a non-zero exit code) the console stayed down until the next reboot, with the installer still reporting "web console set up + started". - `web setup` gates on cert.pem (written last) as well as the token, 90 s budget. - After `schtasks /run`, poll for the :47992 listener and retry before giving up; warn honestly instead of claiming a start that did not happen. - `web-run.cmd` (installed + dev) waits in-process for the token + cert (~5 min) rather than exiting 1 and hoping restart-on-failure retries. - Register the task with a logon trigger alongside boot, falling back to the boot-only XML if a Task Scheduler build rejects it. - Linux had the same defect: punktfunk-web.service's Restart=on-failure gave up permanently after systemd's default 5-starts-in-10 s limit. StartLimitIntervalSec=0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,17 +16,26 @@ set "CERTFILE=%PFDATA%\cert.pem"
|
||||
set "KEYFILE=%PFDATA%\key.pem"
|
||||
|
||||
rem The host's `serve` writes the mgmt token + its identity cert/key on first run. Until they exist
|
||||
rem we have no credential and no TLS material, so fail and let the task's restart-on-failure retry
|
||||
rem (mirrors the Linux unit's Restart=on-failure waiting for the host to create them) rather than
|
||||
rem silently downgrading to plain HTTP.
|
||||
if not exist "%TOKENFILE%" (
|
||||
echo [punktfunk-web] mgmt token not present yet at "%TOKENFILE%" - waiting for the host service.
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%CERTFILE%" (
|
||||
echo [punktfunk-web] host identity cert not present yet at "%CERTFILE%" - waiting for the host service.
|
||||
rem we have no credential and no TLS material, so WAIT rather than silently downgrading to plain HTTP.
|
||||
rem
|
||||
rem Wait in-process instead of exiting 1 and hoping the task's restart-on-failure retries: Task
|
||||
rem Scheduler does not reliably restart on a plain non-zero exit code, so a console that started
|
||||
rem before the host finished writing those files (the token lands at argument parse, the cert only
|
||||
rem after the RSA-2048 keygen) used to stay down until the next reboot. ~5 min at 2 s, then give up
|
||||
rem so a genuinely broken install still surfaces as a failed task rather than one that runs forever.
|
||||
rem `timeout` needs a console this task does not have, so `ping -n 3` is the 2-second sleep.
|
||||
set /a PFWAITS=0
|
||||
:pfwait
|
||||
if exist "%TOKENFILE%" if exist "%CERTFILE%" goto pfready
|
||||
if %PFWAITS% GEQ 150 (
|
||||
echo [punktfunk-web] gave up waiting for "%TOKENFILE%" + "%CERTFILE%" - is the punktfunk host service running?
|
||||
exit /b 1
|
||||
)
|
||||
if %PFWAITS%==0 echo [punktfunk-web] waiting for the host service to write the mgmt token + identity cert...
|
||||
set /a PFWAITS+=1
|
||||
ping -n 3 127.0.0.1 >nul 2>&1
|
||||
goto pfwait
|
||||
:pfready
|
||||
|
||||
rem Both files are single KEY=VALUE lines (LF), written 0600/ACL'd: PUNKTFUNK_MGMT_TOKEN=... and
|
||||
rem PUNKTFUNK_UI_PASSWORD=... . Split on the first '=' and import each into the environment.
|
||||
|
||||
Reference in New Issue
Block a user