diff --git a/docs/RFC.md b/docs/RFC.md index a6af897..678a895 100644 --- a/docs/RFC.md +++ b/docs/RFC.md @@ -14,7 +14,7 @@ go-process provides the implementation behind `c.Process()`. Core defines the primitive (Section 17). go-process registers the Action handlers that make it work. -``` +```text core/go defines: c.Process().Run(ctx, "git", "log") → calls c.Action("process.run").Run(ctx, opts) @@ -37,7 +37,7 @@ The codebase now matches the v0.8.0 target. The bullets below are the historical ### File Layout -``` +```text service.go — main service (factory, lifecycle, process execution) registry.go — daemon registry (PID files, health, restart) daemon.go — DaemonEntry, managed daemon lifecycle @@ -233,7 +233,7 @@ func (p *ManagedProcess) Info() ProcessInfo { Higher-level abstraction over `process.start`: -``` +```text process.start → low level: start a command, get a handle daemon.Start → high level: PID file, health endpoint, restart policy, signals ``` @@ -256,7 +256,7 @@ return core.Result{Value: core.E("process.run", core.Concat("command failed: ", AX-7: `TestFile_Function_{Good,Bad,Ugly}` -``` +```text TestService_Register_Good — factory returns Result TestService_OnStartup_Good — registers 5 Actions TestService_HandleRun_Good — runs command, returns output diff --git a/pidfile.go b/pidfile.go index 1b3d009..bade76f 100644 --- a/pidfile.go +++ b/pidfile.go @@ -1,9 +1,9 @@ package process import ( - "bytes" - "path" + "path/filepath" "strconv" + "strings" "sync" "syscall" @@ -41,7 +41,7 @@ func (p *PIDFile) Acquire() error { defer p.mu.Unlock() if data, err := coreio.Local.Read(p.path); err == nil { - pid, err := strconv.Atoi(string(bytes.TrimSpace([]byte(data)))) + pid, err := strconv.Atoi(strings.TrimSpace(data)) if err == nil && pid > 0 { if proc, err := processHandle(pid); err == nil { if err := proc.Signal(syscall.Signal(0)); err == nil { @@ -52,7 +52,7 @@ func (p *PIDFile) Acquire() error { _ = coreio.Local.Delete(p.path) } - if dir := path.Dir(p.path); dir != "." { + if dir := filepath.Dir(p.path); dir != "." { if err := coreio.Local.EnsureDir(dir); err != nil { return core.E("pidfile.acquire", "failed to create PID directory", err) } @@ -102,7 +102,7 @@ func ReadPID(path string) (int, bool) { return 0, false } - pid, err := strconv.Atoi(string(bytes.TrimSpace([]byte(data)))) + pid, err := strconv.Atoi(strings.TrimSpace(data)) if err != nil || pid <= 0 { return 0, false } diff --git a/specs/api/RFC.md b/specs/api/RFC.md index 158b73f..2de2844 100644 --- a/specs/api/RFC.md +++ b/specs/api/RFC.md @@ -16,7 +16,7 @@ Exported fields: ### Package Functions -- `func NewProvider(registry *process.Registry, hub *ws.Hub) *ProcessProvider`: Returns a `ProcessProvider` for the supplied registry and WebSocket hub. When `registry` is `nil`, it uses `process.DefaultRegistry()`. +- `func NewProvider(registry *process.Registry, service *process.Service, hub *ws.Hub) *ProcessProvider`: Returns a `ProcessProvider` for the supplied registry, optional process service, and WebSocket hub. When `registry` is `nil`, it uses `process.DefaultRegistry()`. When `service` is non-`nil`, provider-runner features are enabled. - `func PIDAlive(pid int) bool`: Returns `false` for non-positive PIDs and otherwise reports whether `os.FindProcess(pid)` followed by signal `0` succeeds. ### `ProcessProvider` Methods