slotgc

package
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package slotgc detects and removes per-slot directories under .bones/swarm/<slot>/ whose leaf process is no longer alive.

The package lives outside both internal/swarm (to avoid an import cycle: hub → swarm → workspace → hub) and internal/hub (so cli's doctor can read without importing the hub start path). It depends only on the standard library and the path convention .bones/swarm/<slot>/leaf.pid that swarm.SlotDir/SlotPidFile encode.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeadSlots

func DeadSlots(workspaceDir string) ([]string, error)

DeadSlots lists slot names under .bones/swarm/<slot>/ whose leaf.pid file points at a process that no longer exists. Slots without a pid file (mid-creation, or already partially cleaned) are skipped — only "had a leaf, leaf is gone" qualifies.

Read-only. Returns nil + nil when the swarm root doesn't exist (workspace never used swarm verbs).

func Kill added in v0.7.1

func Kill(pid int) bool

Kill terminates pid using the same SIGTERM → poll → SIGKILL pattern as hub.terminateProcess and registry.Reap. Returns true if the process is gone by the time Kill returns. Best-effort: callers treat a false return as "still alive after escalation, give up".

func PruneDead

func PruneDead(workspaceDir string) ([]string, error)

PruneDead removes per-slot directories whose leaf.pid file points at a dead PID. Returns the list of slot names actually removed. Errors on individual slot removals are aggregated; the pass continues so a permission-denied on one slot doesn't block cleanup of the rest.

Types

type Slot added in v0.7.1

type Slot struct {
	Name string
	PID  int
}

Slot pairs a slot name with the pid of its live leaf. Returned by LiveSlots so cli/down can render a meaningful plan and signal each pid in turn.

func LiveSlots added in v0.7.1

func LiveSlots(workspaceDir string) ([]Slot, error)

LiveSlots lists slot names under .bones/swarm/<slot>/ whose leaf.pid references a still-alive process. Inverse of DeadSlots; the caller uses this to enumerate processes that bones down should reap. Slots without a pid file are skipped (no leaf to kill).

Read-only. Returns nil + nil when the swarm root doesn't exist.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL