state

package
v0.1.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseDir

func BaseDir() string

BaseDir returns the base gridctl directory (~/.gridctl/).

func CheckAndClean

func CheckAndClean(name string) (bool, error)

CheckAndClean checks if a state file exists and if the process is running. If the process is dead, it removes the state file and returns true (cleaned). If the process is running, it returns false (not cleaned). If no state file exists, it returns false.

func Delete

func Delete(name string) error

Delete removes a state file.

func EnsureLogDir

func EnsureLogDir() error

EnsureLogDir creates the log directory if it doesn't exist.

func IsRunning

func IsRunning(state *DaemonState) bool

IsRunning checks if the daemon process is still running.

func KillDaemon

func KillDaemon(state *DaemonState) error

KillDaemon sends SIGTERM to the daemon process, waits up to 5 seconds for graceful shutdown, then sends SIGKILL if the process is still running.

func LockPath

func LockPath(name string) string

LockPath returns the path to a lock file for a stack.

func LogDir

func LogDir() string

LogDir returns the directory for log files (~/.gridctl/logs/).

func LogPath

func LogPath(name string) string

LogPath returns the path to a log file for a stack.

func Save

func Save(state *DaemonState) error

Save writes a daemon state file.

func StateDir

func StateDir() string

StateDir returns the directory for state files (~/.gridctl/state/).

func StatePath

func StatePath(name string) string

StatePath returns the path to a state file for a stack.

func VerifyPID

func VerifyPID(pid int) bool

VerifyPID checks if a process with the given PID is running.

func WithLock

func WithLock(name string, timeout time.Duration, fn func() error) error

WithLock executes fn while holding an exclusive lock on the stack state. Returns error if lock cannot be acquired within timeout.

Types

type DaemonState

type DaemonState struct {
	StackName string    `json:"stack_name"`
	StackFile string    `json:"stack_file"`
	PID       int       `json:"pid"`
	Port      int       `json:"port"`
	StartedAt time.Time `json:"started_at"`
}

DaemonState represents the state of a running daemon.

func List

func List() ([]DaemonState, error)

List returns all daemon states.

func Load

func Load(name string) (*DaemonState, error)

Load reads a daemon state file.

Jump to

Keyboard shortcuts

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