process

package
v0.0.0-...-334364b Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2016 License: Apache-2.0 Imports: 17 Imported by: 5

Documentation

Index

Constants

View Source
const (
	StateStarted = ProcessState("StateStarted")
	StateStopped = ProcessState("StateStopped")
)

Variables

This section is empty.

Functions

func AddDefaultVars

func AddDefaultVars(vars map[string]string) map[string]string

func ReplaceVars

func ReplaceVars(text string, vars map[string]string) string

Types

type Event

type Event struct {
	Time    time.Time
	Message string
}

type FileLogWriter

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

func NewFileLogWriter

func NewFileLogWriter(file string) (*FileLogWriter, error)

func (FileLogWriter) Close

func (flw FileLogWriter) Close()

func (FileLogWriter) Len

func (flw FileLogWriter) Len() int64

func (FileLogWriter) String

func (flw FileLogWriter) String() string

func (FileLogWriter) Write

func (flw FileLogWriter) Write(p []byte) (n int, err error)

type InMemoryLogWriter

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

func NewInMemoryLogWriter

func NewInMemoryLogWriter() InMemoryLogWriter

func (InMemoryLogWriter) Close

func (imlw InMemoryLogWriter) Close()

func (InMemoryLogWriter) Len

func (imlw InMemoryLogWriter) Len() int64

func (InMemoryLogWriter) String

func (imlw InMemoryLogWriter) String() string

func (InMemoryLogWriter) Write

func (imlw InMemoryLogWriter) Write(p []byte) (n int, err error)

type LogWriter

type LogWriter interface {
	Write(p []byte) (n int, err error)
	String() string
	Len() int64
	Close()
}

type Proc

type Proc interface {
	GetProcID() string
	GetSvcName() string
	IsActive() bool
	Active() ProcRun
	ProcRuns() []ProcRun
	NumOfProcRuns() int
	State() ProcessState
	Start(map[string]string) error
	Stop() error
}

func NewProcess

func NewProcess(procID string, svcName string, executor []string, command string, args []string, stdoutFile string,
	stderrFile string, environment map[string]string, metadata map[string]string, pwd string) (Proc, error)

type ProcMgr

type ProcMgr interface {
	CreateProcess(*ProcessStatus, map[string]string) (Proc, error)
	DestroyProcess(string) error
	StartProcess(string, map[string]string) error
	StopProcess(string) error
	AllProcess() map[string]Proc
	AllActiveProcess() map[string]Proc
	TotalProcess() int
	TotalActiveProcess() int
	FindByProcID(string) Proc
	FindBySvcName(string) map[string]Proc
}

func NewProcessManager

func NewProcessManager() ProcMgr

type ProcRun

type ProcRun interface {
	Start() error
	Signal(syscall.Signal) error
	Kill() error
	WaitingStopped()
	WaitingStoppedInMillisecond(time.Duration) bool
}

type Process

type Process struct {
	ProcID      string
	SvcName     string
	Executor    []string
	Command     string
	Args        []string
	StdoutFile  string
	StderrFile  string
	Environment map[string]string
	Metadata    map[string]string
	Pwd         string
	// contains filtered or unexported fields
}

func (*Process) Active

func (p *Process) Active() ProcRun

func (*Process) GetProcID

func (p *Process) GetProcID() string

func (*Process) GetSvcName

func (p *Process) GetSvcName() string

func (*Process) HoldProcRun

func (p *Process) HoldProcRun(pr ProcRun)

func (*Process) IsActive

func (p *Process) IsActive() bool

func (*Process) NewProcessRun

func (p *Process) NewProcessRun(endpoints map[string]string) ProcRun

func (*Process) NumOfProcRuns

func (p *Process) NumOfProcRuns() int

func (*Process) ProcRuns

func (p *Process) ProcRuns() []ProcRun

func (*Process) SetActive

func (p *Process) SetActive(pr ProcRun)

func (*Process) SetInactive

func (p *Process) SetInactive()

func (*Process) Start

func (p *Process) Start(endpoints map[string]string) error

func (*Process) State

func (p *Process) State() ProcessState

func (*Process) Stop

func (p *Process) Stop() error

type ProcessRun

type ProcessRun struct {
	ID          int
	Commandline string
	Cmd         *exec.Cmd
	Error       error
	Started     time.Time
	Stopped     time.Time
	Events      []*Event
	ProcID      string
	SvcName     string
	StdoutFile  string
	StderrFile  string
	StdoutBuf   LogWriter
	StderrBuf   LogWriter
	Environment map[string]string
	WaitStatus  syscall.WaitStatus
	Pwd         string
	Stopc       chan struct{}
}

func (*ProcessRun) Kill

func (pr *ProcessRun) Kill() error

func (*ProcessRun) Signal

func (pr *ProcessRun) Signal(sig syscall.Signal) error

func (*ProcessRun) Start

func (pr *ProcessRun) Start() error

func (*ProcessRun) String

func (pr *ProcessRun) String() string

func (*ProcessRun) WaitingStopped

func (pr *ProcessRun) WaitingStopped()

func (*ProcessRun) WaitingStoppedInMillisecond

func (pr *ProcessRun) WaitingStoppedInMillisecond(timeout time.Duration) bool

type ProcessRunInfo

type ProcessRunInfo struct {
	HostIP      string
	HostName    string
	HostRegion  string
	HostIDC     string
	Executor    []string
	Command     string
	Args        []string
	Environment map[string]string
	Endpoints   map[string]pkg.Endpoint
}

type ProcessState

type ProcessState string

func (ProcessState) Opposite

func (s ProcessState) Opposite() ProcessState

func (ProcessState) String

func (s ProcessState) String() string

type ProcessStatus

type ProcessStatus struct {
	ProcID       string
	SvcName      string
	MachID       string
	DesiredState ProcessState
	CurrentState ProcessState
	IsAlive      bool
	RunInfo      ProcessRunInfo
}

Jump to

Keyboard shortcuts

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