Skip to content

Run the worker as a Windows service - #1004

Merged
theatrus merged 6 commits into
mainfrom
worker-windows-service
Oct 26, 2026
Merged

theatrus merged 6 commits into
mainfrom
worker-windows-service

Conversation

@theatrus

@theatrus theatrus commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Run a PSF Guard worker as a Windows service so it can process tasks before anyone logs in. #1003 is merged, and this branch is rebased onto main. It includes the revised desktop-worker terminology and preserves the concurrent Windows permissions and process-exit fix.

Open Settings › Workers › Worker on this computer, enter the worker settings, and turn off Start worker at login. Click Save worker settings, then Stop worker if it is running. From PowerShell opened as administrator, run:

psf-guard-cli worker-service install

The command installs and starts PSF Guard Worker under its own virtual account, NT SERVICE\PSFGuardWorker. It copies the executable to %ProgramFiles%\PSF Guard Worker and settings to %ProgramData%\PSF Guard Worker\worker.json. Settings and task files inherit the protected data folder’s permissions. Reinstalling repairs permissions left by earlier installs.

  • After changing settings or updating PSF Guard, run the install command again. It stops the service, waits for its process to exit, updates its copies and restarts it. The service always uses its own tasks folder.
  • The desktop UI distinguishes a running Windows service from a service that has not stopped. Neither status implies a connection to the processing server. Start worker stays disabled until the service stops. Help text explains that desktop controls do not update or restart the Windows service.
  • Stop and Windows preshutdown let the worker disconnect and return unfinished tasks to the server’s queue. During preshutdown, Windows allows up to 60 seconds; the service reports progress every five seconds. Failures are logged before the service stops, and Windows restarts it after 30 seconds.
  • worker-service uninstall stops and removes the service and deletes its copied executable, settings including the token, task files and logs. The desktop app’s saved settings remain separate.

The Workers guide covers updates, permission recovery, RC-Astro licenses, shared storage and removal. Commands, API fields and stored settings remain unchanged by the language edits.

Screenshots

WebKit browser fixtures simulate the Windows service states through the Tauri bridge. They verify the UI wording and disabled controls; they do not exercise a native Windows service.

Service running

Windows service running

Service has not stopped

Windows service has not stopped

Validation

On macOS, after integrating the permissions and process-exit fix:

  • cargo fmt --all -- --check.
  • cargo clippy --workspace --all-targets --all-features -- -D warnings.
  • cargo test --lib --all-features worker: 74 passed, 2 ignored.
  • Frontend lint/build; focused desktop/server worker Vitest files: 13 passed, including running and changing service states.
  • Local Playwright wrapper, desktop-worker and server-worker specs: 8 passed, Chromium and WebKit. Covers service wording and disabled startup, desktop/phone controls, token creation, a real fixture worker joining, and token revocation. Desktop commands and service states are simulated.
  • git diff --check; screenshots visually inspected.

Windows-only modules and their PowerShell permission/process tests do not run on macOS. Native Windows install, stop, shutdown and uninstall remain untested here; hosted Windows checks are separate from these local results.

Operational limits

  • The service account may not have an RC-Astro installation or license available only to the desktop user. Use the desktop worker when that account is required.
  • Reinstalling restores the default service account. Reapply custom account settings in Windows Services afterward.
  • Prevent Windows from sleeping while it needs to process tasks.
  • A refused token causes repeated restarts until its settings are corrected. Save the replacement token and rerun install.
  • Remove the service before uninstalling PSF Guard; the app uninstaller does not remove it.

@theatrus
theatrus force-pushed the worker-windows-service branch 3 times, most recently from 19ed81e to 7ce03ba Compare October 26, 2026 04:02
theatrus and others added 6 commits October 25, 2026 21:32
`psf-guard worker-service install` creates the PSF Guard Worker service,
started with Windows and run as Local System with the worker settings the
desktop app saved (or --config FILE), and starts it. Stop and shutdown let
the worker leave the server, which queues its running task again, while
the service reports a stop pending. A failed run, such as a refused token,
exits nonzero, and the service's failure actions start it again after 30
seconds. `worker-service uninstall` stops and removes it. The service logs
to files starting `worker` in %ProgramData%\PSF Guard\logs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app installs per user, so a service that ran its binary or read its
settings in place would let any program running as that user gain the
service's rights. `worker-service install` now copies the binary to
Program Files and the settings to ProgramData, limits that folder to
SYSTEM, Administrators and the service, and runs the service as its own
virtual account, NT SERVICE\PSFGuardWorker, not Local System. Running it
again updates the copies. The settings path is made absolute; shutdown
uses preshutdown with time for the worker to leave the server; a stop
reports rising checkpoints; a failure logs its reason before the service
reports it stopped, with a service-specific code; uninstall reports
access refused and a stop still in progress, and removes the copies.
Settings › Run a worker shows a running service and offers no second
worker then.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@theatrus
theatrus force-pushed the worker-windows-service branch from ab3527e to e0c23fa Compare October 26, 2026 04:35
@theatrus
theatrus merged commit efdaa64 into main Oct 26, 2026
16 checks passed
@theatrus
theatrus deleted the worker-windows-service branch October 26, 2026 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant