const (
INITPID = 1
STATUS_RUNNING = 1
STATUS_STOPPED = 2
)
const (
READ_MILLIS = 5000
)
var (
LogExe = flag.Bool("ge_debug_exe", false, "debug execution of third party binaries")
)
func Copy(srcFile, dstFile string) error
func CopyDir(srcDir, dest string) error
func CopySymLink(source, dest string) error
func CreateIfNotExists(dir string, perm os.FileMode) error
func CreateStandardAdjacentCgroup() (string, error)
if caller is in cgroup "/LINUXCOM/ancestor/me", new cgrop will be "/LINUXCOM/ancestor/com_1"
func CreateStandardCgroup(dir string) error
func DirSize(dir string) (uint64, error)
if dir is the name of a directory, it will recursively calculate the size. if it is a file, it will stat it and return the filesize
func Exists(filePath string) bool
func MyCgroup() (string, error)
type ComInstance interface {
Wait(ctx context.Context) error // waits for main command to exit. might leave fork'ed children running
WaitAll(ctx context.Context) error // waits for all children to exit as well
Signal(signal syscall.Signal) error
GetCommand() Command
}
type Command interface {
SigInt() error // -2
SigKill() error // -9
SetStdinWriter(r io.Writer)
SetStdoutReader(r io.Reader)
SetStderrReader(r io.Reader)
IsRunning() bool
SetDebug(bool)
Start(ctx context.Context, com ...string) (ComInstance, error)
}
func NewCommand() Command
type LinePrefixPipe struct {
// contains filtered or unexported fields
}
func NewLinePrefixPipe(r io.Reader) *LinePrefixPipe
func (l *LinePrefixPipe) Read([]byte) (int, error)
type Linux interface {
SafelyExecute(cmd []string, stdin io.Reader) (string, error)
SafelyExecuteWithDir(cmd []string, dir string, stdin io.Reader) (string, error)
MyIP() string
SetMaxRuntime(time.Duration)
SetRunForever() // incompatible with setmaxruntime
SetAllowConcurrency(bool)
SetEnvironment([]string)
AddFileDescriptor(fd int)
}
func New() Linux
func NewWithContext(ctx context.Context) Linux
type Loadavg struct {
}
func (g *Loadavg) GetCPULoad(ctx context.Context, req *common.Void) (*common.CPULoad, error)
type ProcessState struct {
// contains filtered or unexported fields
}
func AllPids() ([]*ProcessState, error)
func PidStatus(pid int) *ProcessState
func (ps *ProcessState) Binary() string
func (ps *ProcessState) Cgroup() string
func (ps *ProcessState) Children() ([]*ProcessState, error)
func (ps *ProcessState) ParentPid() int
func (ps *ProcessState) Pid() int
func (ps *ProcessState) Status() STATUS
func (ps *ProcessState) String() string
type STATUS int
func (s STATUS) String() string