Documentation
¶
Index ¶
- Constants
- type PIDManager
- func (pm *PIDManager) AcquireLock() error
- func (pm *PIDManager) Cleanup() error
- func (pm *PIDManager) GetRunningPID() (int, error)
- func (pm *PIDManager) IsProcessRunning(pid int) bool
- func (pm *PIDManager) PIDPath() string
- func (pm *PIDManager) ReadPID() (int, error)
- func (pm *PIDManager) ReleaseLock() error
- func (pm *PIDManager) StopProcess() error
- func (pm *PIDManager) StopProcessWithTimeout(timeout time.Duration) error
- func (pm *PIDManager) WritePID() error
- func (pm *PIDManager) WritePIDForProcess(pid int) error
- type ReferenceCounter
- func (rc *ReferenceCounter) Cleanup() error
- func (rc *ReferenceCounter) Decrement() (bool, error)
- func (rc *ReferenceCounter) DecrementAndCheck() (bool, int, error)
- func (rc *ReferenceCounter) GetCount() int
- func (rc *ReferenceCounter) Increment() error
- func (rc *ReferenceCounter) IncrementAndCheck() (int, error)
- func (rc *ReferenceCounter) Reset() error
- type StartupLock
Constants ¶
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) 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) WithLock ¶
func (sl *StartupLock) WithLock(fn func() error) error
WithLock executes a function while holding the startup lock