Skip to content

Windows spored — cross-platform lifecycle agent as a Windows Service #77

Closed

Description

@scttfrdmn

Goal

Port the spored lifecycle agent to Windows so Windows instances get the same in-instance enforcement Linux gets today (TTL / idle / cost / completion-file / pre-stop). This is Phase 2 of the Windows path scoped in #55 (Phase 1 = target-OS-aware launch + SSM connect + TTL/reaper lifecycle, no agent).

Confirmed by the #55 spike: a Windows instance today boots with no spored at all (buildUserData only emits #!/bin/bash, which Windows EC2Launch ignores), so the only lifecycle safety net is the server-side reaper (#70). That's a backstop, not parity.

What's needed

Build / packaging

  • spored compiled for windows/amd64 (the Go logic is already cross-platform; the OS touchpoints are not).
  • Installed as a Windows Service (or scheduled task), started at boot via PowerShell user-data (<powershell>...</powershell>), not the bash install-spored.sh. Pull the binary from the S3 release bucket like Linux does.

OS touchpoints to port (Linux-specific today)

  • Service management: systemd → Windows Service control.
  • CPU / process sampling for idle detection (/proc-based today) → Windows perf counters / WMI.
  • Completion-file watch: /tmp/SPAWN_COMPLETE → a Windows path (e.g. C:\spawn\SPAWN_COMPLETE); make the path OS-aware, not hardcoded.
  • pre-stop hook: sh -c → PowerShell.
  • Paths, logging location, the self-terminate/stop EC2 calls (these port directly — same SDK).
  • Graceful shutdown on stop/terminate (Linux uses acpid; Windows has its own service-stop signal).

Launch integration (depends on #55 Phase 1)

  • Target-OS-aware buildUserData: emit PowerShell bootstrap for Windows instead of bash.
  • The release workflow already builds for multiple arch; add a spored.exe (windows/amd64) artifact + S3 upload.

Dependencies / related

Acceptance

  • A Windows instance launched by spawn runs spored as a service, enforces TTL/idle/completion/pre-stop in-instance, and self-terminates like Linux — no longer dependent solely on the reaper backstop.

Activity

  1. scttfrdmn commented on Jun 9, 2026

    @scttfrdmn
    ContributorAuthor

    ✅ Windows spored complete — verified end-to-end on real Windows EC2 (v0.38.1)

    spored now runs on Windows as a native Windows Service with full lifecycle parity, deployed via S3 exactly like Linux.

    Shipped across 5 PRs:

    Real Windows EC2 verification (v0.38.1): launch → EC2Launch user-data installs AWS CLI → downloads spored.exe from regional S3 → installs + starts the Windows Service → spored runs as the EC2 provider → reads its config from EC2 tags (Config: TTL=15m0s) → registers DNS → monitor loop runs → self-terminates at the TTL deadline. Zero leaks.

    The --ttl-required Phase 1 guard is relaxed: --idle-timeout is accepted now that idle works in-instance.

    Deferred (non-lifecycle-critical): the optional observability metrics collector (pkg/agent/metrics.go) still reads /proc and degrades gracefully on Windows; a few /var/lib/spored runtime paths (push token, plugin state, queue) are Unix-shaped on Windows but non-fatal (optional features). Both can be follow-ups.

    Closes the "no in-instance agent on Windows" caveat from #55.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions