utils

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ExeName      string
	ExePath      string
	ExeDirectory string
)

Functions

func GetDefaultShell

func GetDefaultShell() []string

func RestartSelf added in v1.2.0

func RestartSelf() error

Types

type CommandConfig

type CommandConfig struct {
	Command    string            `json:"command" validate:"required"`
	Hidden     *bool             `json:"hidden"`
	Shell      string            `json:"shell"`
	ShowErrors bool              `json:"show_errors"`
	ShowOutput bool              `json:"show_output"`
	Detached   bool              `json:"detached"`
	Env        map[string]string `json:"env"`
}

type CommandResult added in v1.4.0

type CommandResult struct {
	Stdout []byte `json:"stdout"`
	Stderr []byte `json:"stderr"`
	Code   int    `json:"code"`
}

func RunCommand

func RunCommand(cfg CommandConfig) (CommandResult, error)

RunCommand runs a specified command, if Detached is true the command result will be empty

type InstanceLock

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

func LockAndKill

func LockAndKill() *InstanceLock

func NewInstanceLock

func NewInstanceLock() InstanceLock

func (InstanceLock) KillLockedPid

func (l InstanceLock) KillLockedPid() error

KillLockedPid kills the process with the pid in the lock file

func (InstanceLock) Lock

func (l InstanceLock) Lock() error

Lock writes the current process id to the lock file

func (InstanceLock) LockedPid

func (l InstanceLock) LockedPid() (int, error)

LockedPid returns the pid in the lock file

func (InstanceLock) LockedProcess

func (l InstanceLock) LockedProcess() (*process.Process, int, error)

LockedProcess returns the process with the pid in the lock file can return os.ErrNotExist or process.ErrorProcessNotRunning

func (InstanceLock) Unlock

func (l InstanceLock) Unlock()

Unlock removes the lock file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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