Add internal/control: an HTTP/1.1 control plane the daemon hosts on a 0600 Unix socket (control.sock) in the config dir — GET /state, GET /events (SSE), POST /pause|/resume — plus a stdlib net/http client (DialState/Pause/Resume) that returns a typed ErrNotRunning when the daemon is down so callers can fall back. Wire into the daemon: paused atomic.Bool gates runMount's trigger loop (drains while paused, no-ops the initial nudge), a per-mount nudge registry lets Resume catch every mount up, and StateSnapshot feeds /state. The control server starts in Run and is non-fatal — sync never depends on it. Windows gets a build-tagged stub (named-pipe upgrade path noted). CLI: devbox pause/resume call the client (friendly 'daemon not running' when absent); status prefers the live socket but ONLY on a TTY, so piped output stays byte-identical to v1 for scripts.
33 lines
1 KiB
Go
33 lines
1 KiB
Go
//go:build windows
|
|
|
|
package control
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
)
|
|
|
|
// ponytail: Windows gets a stub, not a real control plane. The fleet runs
|
|
// darwin/linux; a Windows port should serve the same HTTP/1.1 API over a named
|
|
// pipe (`\\.\pipe\devbox-control`) via Microsoft's go-winio — swap the
|
|
// net.Listen("unix", …) in server.go for winio.ListenPipe and the client's
|
|
// net.Dial for winio.DialPipe. Until a Windows user exists, we don't build it.
|
|
|
|
// Daemon is the slice of the running daemon the control server would steer.
|
|
type Daemon interface {
|
|
StateSnapshot() State
|
|
Pause()
|
|
Resume()
|
|
}
|
|
|
|
// Server is a no-op on Windows.
|
|
type Server struct{}
|
|
|
|
// Serve reports that the control socket isn't supported on Windows yet. The
|
|
// daemon warns and continues; sync is unaffected.
|
|
func Serve(_ context.Context, _ string, _ Daemon, _ func(string, ...any)) (*Server, error) {
|
|
return nil, errors.New("control socket not supported on windows yet")
|
|
}
|
|
|
|
// Publish is a no-op on Windows.
|
|
func (s *Server) Publish(_, _ string) {}
|