lock

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lock provides the single-instance lock for agent runs. It is an OS lock (flock on Unix, a named mutex on Windows) rather than a PID file, so the kernel drops it on any exit — os.Exit, signal, SIGKILL, crash — and no stale or forged file can block later runs.

Index

Constants

This section is empty.

Variables

View Source
var ErrHeld = errors.New("another instance is already running")

ErrHeld means another instance holds the lock.

Functions

func SetTargetForTest added in v1.18.0

func SetTargetForTest(target string) (restore func())

SetTargetForTest points the lock at another file (Unix) or mutex name (Windows) and returns a func restoring the previous one. Tests only.

Types

type Lock

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

Lock represents an acquired instance lock.

func Acquire

func Acquire(_ executor.Executor) (*Lock, error)

Acquire takes the instance lock without blocking. It returns an error wrapping ErrHeld when another instance (any account) holds it.

func (*Lock) Release

func (l *Lock) Release()

Release drops the lock. Safe to call more than once.

Jump to

Keyboard shortcuts

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