lock

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package lock provides the machine-wide process lock shared by runner run and destructive maintenance commands.

Index

Constants

View Source
const DefaultPath = "/tmp/runner.lock"

Variables

View Source
var ErrAlreadyRunning = errors.New("another runner is already running")

Functions

func Acquire

func Acquire(path string, info Info) (release func(), err error)

Acquire obtains a non-blocking exclusive flock. The file is opened with O_NOFOLLOW and verified as regular so a privileged service cannot be tricked into following a /tmp symlink. The file deliberately remains in place after release: unlinking a flock file can split contenders across two inodes and break mutual exclusion. The lock guards against accidentally starting a second runner; it is not a security boundary against local users.

Types

type AlreadyRunningError

type AlreadyRunningError struct {
	Path string
	Info *Info
}

AlreadyRunningError includes best-effort information about the process that currently holds the lock.

func (*AlreadyRunningError) Detail added in v0.16.0

func (e *AlreadyRunningError) Detail() string

Detail names the lock's holder: its PID, start time and config when the lock file records them, else the held lock's path.

func (*AlreadyRunningError) Error

func (e *AlreadyRunningError) Error() string

func (*AlreadyRunningError) Unwrap

func (e *AlreadyRunningError) Unwrap() error

type Info

type Info struct {
	PID        int       `json:"pid"`
	StartedAt  time.Time `json:"started_at"`
	ConfigPath string    `json:"config_path,omitempty"`
}

Info is diagnostic metadata stored in the lock file. The kernel flock is the only source of truth; this content may be stale or malformed.

Jump to

Keyboard shortcuts

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