Forward a direct LuminaryWindow launch through the bundle launcher so it starts desktop mode instead of showing a signed-out page. Refresh the guide screenshots and version the release as 0.5.0 Beta.
18 KiB
Windows launcher design
The launcher is not part of the app: it only chooses a port, sets environment
variables the server already reads, starts node.exe, and gets the user to the
browser. Nothing here requires a change to server/ or src/.
Two implementations ship from the same rules:
| File | Built when | Process lifetime | Console |
|---|---|---|---|
Luminary.ps1 + Luminary.cmd / Luminary.vbs |
always (no toolchain) | launcher exits after the browser opens, node keeps running | none via .vbs, brief via .cmd |
go/main.go → Luminary.exe |
a Go toolchain is present (--launcher go, or automatically under windows/Dockerfile) |
launcher stays alive, removes its state file when the server exits | none (-H windowsgui) |
Luminary.ps1 is always included because Stop Luminary.cmd calls it in both
modes.
Bundle layout the launcher assumes
Luminary\
node.exe
Luminary.exe | Luminary.cmd / Luminary.vbs
Luminary.ps1
Stop Luminary.cmd
runtime.json (created at run time)
logs\server.out.log
logs\server.err.log
logs\launcher.log (Go launcher only)
app\server\index.mjs
app\dist\
app\node_modules\
root is the folder containing the launcher executable/script, never the
current working directory, so shortcuts and "Run as administrator" behave the
same.
1. Single instance
There is no mutex and no named object. The state file runtime.json records
{ pid, port, url, data, started }, and health is the liveness test:
runtime.json exists
└─ GET http://127.0.0.1:<port>/api/health == 200 ?
yes → open the browser on that URL, exit 0 (do not start a second server)
no → stale entry: start a new server and overwrite runtime.json
Why not check the PID: Windows reuses PIDs, and os.FindProcess/Get-Process
can succeed for an unrelated process. A health response from the recorded port
also proves the port belongs to this server instance.
Why not a lock file: a crashed server must not lock the user out. The health probe self-heals in one request.
A second launch while the first server is still booting waits for it instead of racing:
runtime.json pid is alive but health is not up yet
└─ poll /api/health for up to 120 s
ok → open the browser, exit 0 (no second server, no second port)
dead → that boot crashed; fall through and start a fresh server
alive but still unhealthy after 120 s → dialog with the log location, exit 1
The PID is only used to ask "is a boot in progress?", never as proof of life on
its own: health still decides whether the recorded server is usable. Two
launches landing within the same millisecond can both pass the check before
either writes runtime.json; they then bind different ports and both serve the
same catalog (SQLite WAL tolerates that). A mutex with stale-lock recovery would
close that window, at the cost of a failure mode where a crashed boot locks the
user out; for a desktop launcher a second browser tab is the better trade.
2. Port policy
- Preference order:
8787, then8788…8887(100 candidates). - A port is taken if a
TcpListenercannot bind it on127.0.0.1(PowerShell) /net.Listen("tcp", "127.0.0.1:<port>")(Go). - The chosen port is passed as
PORT; the server already reads it (server/config.mjs), and the browser URL is built from the same value. - Ports are never inherited from the environment: a stale
PORTexported by a shell must not make the launcher open the wrong URL. - Loopback only:
HOST=127.0.0.1avoids the Windows Firewall prompt and the app is a single-user desktop install. For LAN proofing galleries the user setsHOST=0.0.0.0in the environment before starting, or editsLuminary.ps1— documented, not the default.
3. Data directory
Precedence, first match wins:
LUMINARY_DATA— already exported (a power user or an installer can pin it).%LOCALAPPDATA%\Luminary\data.%USERPROFILE%\AppData\Local\Luminary\dataifLOCALAPPDATAis empty.
Never inside app\: an update replaces app\ wholesale, and %ProgramFiles%
is read-only for a non-admin user. The launcher creates the directory with
MkdirAll/New-Item -Force before starting the server; the server also creates
it, but a clear write failure from the launcher is a better error than a stack
trace in a hidden log.
The folder holds the SQLite catalog (plus -wal/-shm), secret.key and all
image folders. Backups copy this folder while the server is stopped.
When the bundle folder is not writable (write-protected USB, %ProgramFiles%
for a non-admin user) two things move into the data folder: runtime.json and
the logs folder. The launcher probes the bundle folder with a throwaway file
before choosing, so checklist case 6 still starts.
4. Environment contract
Only variables the server already understands are set:
| Variable | Value |
|---|---|
PORT |
chosen port |
HOST |
127.0.0.1 |
NODE_ENV |
production |
LUMINARY_DATA |
resolved data directory |
LUMINARY_INVITE, SMTP, quota and bridge settings are left alone; they are
admin-editable in the UI or set by a power user in the environment.
The child inherits the rest of the environment (Start-Process and
cmd.Env = append(os.Environ(), …)).
5. Start and health wait
create data dir → create log dir → pick port → spawn node.exe (hidden)
→ write runtime.json
→ poll /api/health every 700 ms, up to 120 s
ok → open http://127.0.0.1:<port> and return
fail → print/record the last 20 lines of stderr, kill the child,
remove runtime.json, exit 1
- 120 s covers a Defender scan of
node.exepluslibraw.wasmon a cold boot. - The poll interval is short enough that a warm start feels instant (usually the second or third attempt).
- The PowerShell launcher checks
$process.HasExitedfirst, so a crash reports the log instead of waiting the full timeout. - The browser is opened only after health succeeds; opening earlier shows a connection error on slow machines.
Logs are append-only: logs\server.out.log and logs\server.err.log from the
child, logs\launcher.log from the Go launcher. They fall back to
<data>\logs when the bundle folder is read-only. Rotation is not implemented;
the files are small (startup lines plus request errors) and a support note says
they can be deleted while the server is stopped.
6. Stop
Stop Luminary.cmd → Luminary.ps1 -Stop:
- Read
runtime.json; if absent or the process is gone → "not running" (exit 0, idempotent). taskkill /PID <pid> /T /F—/Talso covers any helper processes,/Fbecause the server has no shutdown hook to answer a polite close.- Delete
runtime.json.
Because runtime.json is written only after a successful spawn, Stop never
kills an unrelated process unless the file is stale and the PID has been
reused. The window is tiny; the health probe in the start path avoids creating
that state, and a support note explains deleting runtime.json by hand.
With the Go launcher, Stop kills the child, cmd.Wait() returns, the launcher
removes runtime.json itself and exits 0. The launcher never outlives the
server.
7. Status
Luminary.ps1 -Status prints PID, URL, health state and the data directory.
Useful for support without opening Task Manager.
8. Upgrade flow
Stop Luminary.cmd.- Replace
app\(andnode.exeif the bundle ships a newer runtime) from the new bundle. Keepruntime.json,logs\and the data folder. - Start again. The server migrates the SQLite schema on boot.
The launcher does not version-check; version.txt in the bundle root records
the Luminary version, commit and Node version for support.
9. Incomplete bundle diagnostics
The launcher is a few files next to a large app\ tree, so the three realistic
failure modes are a zip that was opened instead of extracted, an antivirus that
quarantined node.exe, and a launcher copied out of the source tree. All three
look identical from the outside ("node.exe is missing"), so the launcher checks
node.exe, app\server\index.mjs and app\dist\index.html, treats zero-byte
files as missing, and prints the fix for each cause:
| Entry point | Behaviour |
|---|---|
Luminary.cmd -Verify |
prints the bundle path, each required file with its size, the version from version.txt, and exits 3 on a problem |
Luminary.cmd |
same diagnosis on stderr/stdout, then exits 3 instead of pretending to start |
Luminary.vbs |
a message box before PowerShell is even started, because a silent exit would look like nothing happened |
Luminary.exe |
a MessageBoxW dialog (it is linked with -H windowsgui, so there is no console) and a line in logs\launcher.log |
version.txt records node <version> win-x64 sha256 <hash> size <bytes>, so the
help text can quote the exact hash the build verified against nodejs.org, and
the launcher can spot a truncated file by size without hashing 94 MB on every
launch.
10. Preflight checks
Test-Platform runs before the runtime is resolved, and -Status prints the
same report. It checks only what the bundle actually needs — taken from the
shipped binaries' PE imports, not from a generic checklist:
| Check | Source | Result |
|---|---|---|
| Windows 10+ | HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentBuild ≥ 10240 |
blocking dialog, exit 4 |
| 64-bit | PROCESSOR_ARCHITECTURE is AMD64 or ARM64 |
blocking dialog, exit 4 |
| Universal C Runtime | %SystemRoot%\System32\ucrtbase.dll |
blocking dialog with the KB2999226 link |
| free space on the data drive | DriveInfo.AvailableFreeSpace |
note below 2 GB, blocking below 200 MB |
| ARM64 | PROCESSOR_ARCHITECTURE |
note: x64 emulation, slower RAW decode |
Why the list is this short:
node.exeimports only system DLLs (KERNEL32, ADVAPI32, WS2_32, CRYPT32, USER32, …) and links the C runtime statically, so the Visual C++ Redistributable is not required. Checked withobjdump -pon the bundled binary.libvips-42.dllimports the UCRT (api-ms-win-crt-*), which ships with Windows 10/11. It does not importvcruntime140.dllormsvcp140.dll.- The only native modules in the bundle are sharp's three files plus
libraw.wasm; SQLite comes fromnode:sqlite, not a native addon. - PowerShell 5.1 is part of Windows 10/11, and the
.vbsentry point checks for it explicitly before launching anything.
The launcher cannot install a Windows update, so a missing UCRT is explained
with its KB number and URL rather than "fixed". The one artefact it can fetch
itself is node.exe: -Repair does it, and a launch with no usable runtime
offers the same download in a Yes/No dialog.
11. Desktop mode and the app window
Both launchers set LUMINARY_LOCAL=1; nothing else does.
| Behaviour | Effect |
|---|---|
| boot | prepareLocalOwner() creates local@luminary (random password, admin) when missing |
| request with no session | currentUser() returns the local owner |
GET /api/auth/me |
200, so the UI never shows the signup or sign-in view |
POST /api/auth/register |
403 |
POST /api/auth/login |
returns the local session, so a stale login form cannot trap the user |
| edit/delete the local owner | 403, it is launcher-managed |
HOST not loopback |
a warning at boot; the random password means there is nothing to guess |
The app window uses the browser already on the machine:
msedge.exe --app=http://127.0.0.1:<port>
--user-data-dir=%LOCALAPPDATA%\Luminary\data\window-profile
--window-size=1500,950 --no-first-run --no-default-browser-check
--app removes tabs, the address bar and the browser chrome; the separate
profile keeps the app out of the user's normal history and bookmarks.
Window preference, first match wins:
LuminaryWindow.exein the bundle root — a WinForms + WebView2 host with its own icon, taskbar entry and window state (--url <url>). Built fromlauncher/webview2with the .NET 8 SDK, published self-contained, so the target machine needs no .NET; it does need the WebView2 runtime, which ships with Windows 10/11 alongside Edge. Missing runtime → a dialog with the Evergreen link, not a silent exit.- Edge
--app, then Chrome--app. - The default browser (
-Browser/LUMINARY_WINDOW=browserforces this).
The wrapper is only a window: node stays a child of the launcher, Stop still
uses runtime.json, and the browser window remains the fallback when the exe
is absent or fails to start. A direct launch without --url forwards to the
bundle launcher and exits immediately; that closes the old hole where
double-clicking the window opened port 8787 directly and showed a login page
(or a dead URL) because no desktop-mode server was running.
12. Runtime resolution and repair
Three states, checked in order:
Bundled node.exe |
Runtime used | What the user sees |
|---|---|---|
| present, size matches the pin | node.exe |
nothing |
| missing, empty, or wrong size | system Node 24+ from PATH, %ProgramFiles%\nodejs, %ProgramFiles(x86)%\nodejs, %LOCALAPPDATA%\Programs\nodejs, %NVM_SYMLINK% |
a warning line and one information dialog naming the path, with the repair command |
| neither | none | error dialog listing the three causes, exit 3 |
The fallback is deliberately not silent: an app quietly running a different
runtime is a support mystery, and the user should be told to run -Repair.
Node below 24 is rejected because server/denoise-worker.mjs imports a .ts
module, which needs the type-stripping runtime.
-Repair (PowerShell and Luminary.exe -repair) does the following:
- refuses while the server is running — the file is locked, and replacing a runtime under a live process is wrong anyway;
- reads the version and hash from
version.txt, falling back tonodejs.org/dist/v<version>/SHASUMS256.txtwhen the bundle predates the hash line; - downloads to a temp file (
LUMINARY_NODE_URLoverrides the URL for a mirror or an air-gapped copy); - hashes the download and refuses to install anything that does not match the
pin — a corporate proxy's HTML error page never becomes
node.exe; - replaces
node.exeatomically (node.exe.new+ rename) and re-runs the bundle check.
13. Security notes
- Binds loopback by default; no firewall rule is needed.
- Everything runs as the logged-in user; the installer is per-user, no UAC.
- The launcher is unsigned, so SmartScreen may warn on first run. Signing the
launcher (and ideally
node.exeprovenance) is a distribution task, not a code one. - The data folder is protected by normal user-profile ACLs.
14. Known limitations and phase 2
- No tray icon. Closing the browser does not stop the server; Stop is a
shortcut. A tray build needs
Shell_NotifyIcon(Go with Win32 calls, or C#), roughly a day of work, and can be swapped in without touching the app. - No auto-update. Replacing
app\is manual. An updater would read a version manifest next to the release and download a zip. - No service mode. Running before login needs WinSW/NSSM and a fixed account/data directory; that is a different install profile, not a launcher change.
- Localhost only. Multi-device proofing galleries need
HOST=0.0.0.0and a firewall rule; that is deliberate for a default desktop install.
15. Test checklist (Windows VM, no Node installed)
- Fresh double-click → data folder created, browser opens, login page loads.
- Second double-click → the running instance is reused and the browser opens; no second process, whether the first server is answering or still booting.
Stop Luminary.cmd→ process gone,runtime.jsonremoved, Stop again says "not running".- Kill node.exe in Task Manager, start again → new port if the old one is held, otherwise the same port, and the catalog is intact.
- Port 8787 occupied by another app → launcher uses 8788 and opens that URL.
- Read-only install folder (Program Files) with data in
%LOCALAPPDATA%→ starts fine (data path is outside the bundle). - RAW import, denoise (proves the
.tsworker), export — i.e. the server is fully functional from the bundle. - Path with spaces and non-ASCII characters (e.g.
C:\Users\Zoë\Luminary) → the quoted entry point and-WorkingDirectorystill work. - Power loss / hard reboot → stale
runtime.jsonis ignored and replaced. - Delete
node.exe, thenLuminary.cmd -Verify→ exit code 3 and the three causes;Luminary.vbs→ message box instead of a silent no-op. - Run
Luminary.cmdfrom inside the zip preview → the "not a complete bundle" message, not a missing-file crash. - On a machine with Node 24 installed: delete
node.exe→ the launcher warns, starts on the system Node and-Statusnames that path;-Stopstill works. - Double-click
LuminaryWindow.exewith no arguments → it exits, the bundle launcher starts desktop mode, and the reopened window is signed in; no login screen appears. - On a machine with no Node: delete
node.exe→ the launch offers the 90 MB download; Yes installs and starts, No exits 3;-Repairworks as well. - Truncate
node.exe(keep the first 100 kB) →-Verifyreportsdamaged, and-Repairreplaces it. A partial file is the usual antivirus outcome. -Repairwhile the server is running → refused with the stop instruction.- Write-protect the bundle folder (or use
%ProgramFiles%without admin) →runtime.jsonandlogsmove to the data folder and the app starts. - Clean Windows 10/11 VM with no Node, no .NET and no VC++ redistributable →
the app starts (proves the import analysis above);
-Statusreports the build, architecture and Node source. - Windows 8.1 (if available) → the UCRT dialog with the KB2999226 link; Windows 7 → the "needs Windows 10 or 11" dialog, exit 4.
- Fresh data folder → no signup and no sign-in screen; the app is signed in as Local, with no account pill in the top bar and no team/admin entry.
- Restart → the same local account and catalog; delete the data folder → a fresh one with no prompt.
- Default launch → chromeless window, no address bar, own window size;
-Browser→ a normal tab. - Start the server by hand with
HOST=0.0.0.0andLUMINARY_LOCAL=1→ the boot log warns that every client is the local admin. - Bundle with
LuminaryWindow.exe→ native window with the Luminary icon in the title bar and taskbar;Stop Luminary.cmdstill ends the server. - Remove the WebView2 runtime (or use an image without it) → the native window shows the download link instead of disappearing.