process

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultShutdownTimeout = 30 * time.Second

DefaultShutdownTimeout is the default timeout for graceful shutdown

Variables

This section is empty.

Functions

This section is empty.

Types

type PIDManager

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

PIDManager handles PID file operations with proper locking

func NewPIDManager

func NewPIDManager() (*PIDManager, error)

NewPIDManager creates a new PID manager

func (*PIDManager) AcquireLock

func (pm *PIDManager) AcquireLock() error

AcquireLock attempts to acquire an exclusive lock by creating PID file

func (*PIDManager) Cleanup

func (pm *PIDManager) Cleanup() error

Cleanup removes the PID file with locking

func (*PIDManager) GetRunningPID

func (pm *PIDManager) GetRunningPID() (int, error)

GetRunningPID returns the PID if the service is running, 0 otherwise

func (*PIDManager) IsProcessRunning

func (pm *PIDManager) IsProcessRunning(pid int) bool

IsProcessRunning checks if a process with the given PID is running (Unix-specific)

func (*PIDManager) PIDPath

func (pm *PIDManager) PIDPath() string

PIDPath returns the path to the PID file

func (*PIDManager) ReadPID

func (pm *PIDManager) ReadPID() (int, error)

ReadPID reads the PID from file with shared locking

func (*PIDManager) ReleaseLock

func (pm *PIDManager) ReleaseLock() error

ReleaseLock releases the lock by removing PID file

func (*PIDManager) StopProcess

func (pm *PIDManager) StopProcess() error

StopProcess stops the running process with graceful shutdown

func (*PIDManager) StopProcessWithTimeout

func (pm *PIDManager) StopProcessWithTimeout(timeout time.Duration) error

StopProcessWithTimeout stops the running process with configurable timeout

func (*PIDManager) WritePID

func (pm *PIDManager) WritePID() error

WritePID writes the current process PID to file

func (*PIDManager) WritePIDForProcess

func (pm *PIDManager) WritePIDForProcess(pid int) error

WritePIDForProcess writes a specific process PID to file with locking

type ReferenceCounter

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

ReferenceCounter manages reference counting for Claude Code instances

func NewReferenceCounter

func NewReferenceCounter() (*ReferenceCounter, error)

NewReferenceCounter creates a new reference counter

func (*ReferenceCounter) Cleanup

func (rc *ReferenceCounter) Cleanup() error

Cleanup removes the reference count file

func (*ReferenceCounter) Decrement

func (rc *ReferenceCounter) Decrement() (bool, error)

Decrement atomically decrements the reference count

func (*ReferenceCounter) DecrementAndCheck

func (rc *ReferenceCounter) DecrementAndCheck() (bool, int, error)

DecrementAndCheck decrements the count and returns whether it reached zero

func (*ReferenceCounter) GetCount

func (rc *ReferenceCounter) GetCount() int

GetCount returns the current reference count

func (*ReferenceCounter) Increment

func (rc *ReferenceCounter) Increment() error

Increment atomically increments the reference count

func (*ReferenceCounter) IncrementAndCheck

func (rc *ReferenceCounter) IncrementAndCheck() (int, error)

IncrementAndCheck increments the count and returns the new value

func (*ReferenceCounter) Reset

func (rc *ReferenceCounter) Reset() error

Reset resets the reference count to zero

type StartupLock

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

StartupLock provides process-wide locking for startup operations

func NewStartupLock

func NewStartupLock() (*StartupLock, error)

NewStartupLock creates a new startup lock

func (*StartupLock) Cleanup

func (sl *StartupLock) Cleanup() error

Cleanup removes the lock file

func (*StartupLock) TryLock

func (sl *StartupLock) TryLock() (bool, error)

TryLock attempts to acquire an exclusive lock for startup Returns true if lock was acquired, false if another process holds the lock

func (*StartupLock) Unlock

func (sl *StartupLock) Unlock() error

Unlock releases the startup lock

func (*StartupLock) WithLock

func (sl *StartupLock) WithLock(fn func() error) error

WithLock executes a function while holding the startup lock

Jump to

Keyboard shortcuts

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