instancelock

package
v0.156.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Acquire

func Acquire(runtimeDir, stateDir, configPath, version string) (*Lock, bool, Owner, error)

Acquire attempts to take the Agentic instance lock for runtimeDir. The returned bool is false when another live process currently holds the lock; in that case owner contains any metadata that could be read.

func LockPath

func LockPath(runtimeDir string) string

LockPath returns the path used for the OS-held advisory lock.

func MetadataPath

func MetadataPath(runtimeDir string) string

MetadataPath returns the path used for diagnostic owner metadata.

Types

type Lock

type Lock struct {
	// contains filtered or unexported fields
}

Lock represents an acquired instance lock. Call Close when the desktop app exits.

func (*Lock) Close

func (l *Lock) Close() error

Close releases the instance lock. The metadata file is intentionally left in place: it is overwritten by the next owner and ignored unless the lock is actively held, which avoids races with a fast successor process.

func (*Lock) Owner

func (l *Lock) Owner() Owner

Owner returns the metadata written when the lock was acquired.

type Owner

type Owner struct {
	PID       int       `json:"pid"`
	PGID      int       `json:"pgid,omitempty"`
	StartedAt time.Time `json:"started_at"`
	StateDir  string    `json:"state_dir"`
	Config    string    `json:"config_path"`
	Version   string    `json:"version,omitempty"`
}

Owner is best-effort metadata about the process holding an Agentic instance lock. It is diagnostic only; the OS-held lock is the authority.

func ReadOwner

func ReadOwner(runtimeDir string) (Owner, error)

ReadOwner reads best-effort owner metadata. Missing metadata is not an error because the lock file itself, not this metadata, is authoritative.

Jump to

Keyboard shortcuts

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