Documentation ¶
Index ¶
- Constants
- Variables
- func Async(f func() error) chan error
- func AsyncTimeout(timeout time.Duration, f func() error) chan error
- func GetProcessInfo(pid int32) (cupPercent float64, useMem uint64, err error)
- func NewDaemonManager(dirPath, nodeKey string) *local
- func StdoutStatusListener(event FSMStatusEvent)
- type CheckHealth
- type CheckMode
- type Command
- type FSMState
- type FSMStatusEvent
- type FSMStatusListener
- type Manager
- type Process
- type ProcessGroup
- type ProcessLogger
- type Program
- type Tags
- type TailLogger
Constants ¶
View Source
const ( Ready = FSMState("ready") Starting = FSMState("starting") Running = FSMState("running") Fail = FSMState("fail") RetryWait = FSMState("retry") Stopping = FSMState("stopping") Stoped = FSMState("stoped") )
View Source
const LOGGER_LINES_NUM = 100
Variables ¶
View Source
var ErrAsyncTimeout = errors.New("Timeout")
Functions ¶
func NewDaemonManager ¶
func NewDaemonManager(dirPath, nodeKey string) *local
func StdoutStatusListener ¶
func StdoutStatusListener(event FSMStatusEvent)
Types ¶
type CheckHealth ¶
type Command ¶
type Command struct { //程序运行体 Command string `json:"command,omitempty"` //启动参数 Args []string `json:"args,omitempty"` //监控检车接口 CheckHealth *CheckHealth `json:"health,omitempty"` }
程序命令,(启动或停止)
type FSMStatusEvent ¶
type FSMStatusListener ¶
type FSMStatusListener func(event FSMStatusEvent)
type Manager ¶
type Manager interface { Start() error Stop() error GetProcess(name string) (*Process, error) AddProgram(program *Program) error RemoveProgram(name string, skip bool) error ModifyProgram(program *Program) error ModifyTag(name string, add bool, tag string) error ListProgramNames() ([]string, error) ListProcess() ([]*Process, error) SetStatusListener(lis FSMStatusListener) StartProgram(name string, determinedResult chan *Process) error StopProgram(name string) error MustGetProcess(name string) *Process MustAddProgram(program *Program) MustRemoveProgram(name string, skip bool) MustModifyProgram(program *Program) MustModifyTag(name string, add bool, tag string) MustListProgramNames() []string MustListProcess() []*Process MustStartProgram(name string, determinedResult chan *Process) MustStopProgram(name string) SubscribeLogger(uid string, name string, tail TailLogger, firstLine int) error UnSubscribeLogger(uid, name string) error }
type Process ¶
type Process struct { Pid int `json:"pid"` Status FSMState `json:"status"` *Program Cpu float64 `json:"cpu"` Rss uint64 `json:"rss"` // contains filtered or unexported fields }
func NewProcess ¶
func (*Process) GetLogger ¶
func (f *Process) GetLogger() *ProcessLogger
type ProcessGroup ¶
type ProcessGroup []*Process
func (ProcessGroup) Len ¶
func (pl ProcessGroup) Len() int
func (ProcessGroup) Less ¶
func (pl ProcessGroup) Less(i, j int) bool
func (ProcessGroup) Names ¶
func (pl ProcessGroup) Names() []string
func (*ProcessGroup) Remove ¶
func (pl *ProcessGroup) Remove(name string) error
func (ProcessGroup) Swap ¶
func (pl ProcessGroup) Swap(i, j int)
type ProcessLogger ¶
type ProcessLogger struct {
// contains filtered or unexported fields
}
func NewLogger ¶
func NewLogger(loggerFile string) (logger *ProcessLogger, err error)
func (*ProcessLogger) Close ¶
func (self *ProcessLogger) Close() error
func (*ProcessLogger) CtrlC ¶
func (self *ProcessLogger) CtrlC(id string)
func (*ProcessLogger) Tail ¶
func (self *ProcessLogger) Tail(id string, tail TailLogger, lines int)
type Program ¶
type Program struct { //程序唯一性ID,使用UUID方式 Id uint64 `json:"id"` Node string `json:"node,omitempty"` Daemon string `json:"daemon"` //程序名称 Name string `json:"name"` Description string `json:"description,omitempty"` //程序标签 Tags Tags `json:"tags"` //工作目录 WorkDir string `json:"workDir,omitempty"` //启动使用用户 User string `json:"user,omitempty"` //环境参数变量 Envs []string `json:"envs,omitempty"` //是不是守护程序,如果是需要提供启动和停止命令 前台程序 Start *Command `json:"start"` //启动停止命令 Stop *Command `json:"stop,omitempty"` //忽略,deamon类型的程序已经启动,也会直接加入管理 IgnoreAlreadyStarted bool `json:"ignoreStarted,omitempty"` //是否自动启动 AutoStart bool `json:"autoStart,omitempty"` //启动周期 StartDuration int `json:"startDuration,omitempty"` //启动重试次数 StartRetries int `json:"startRetries,omitempty"` StopSign syscall.Signal `json:"stopSign,omitempty"` //结束运行超时时间 StopTimeout int `json:"stopTimeout,omitempty"` AddTime time.Time `json:"addTime,omitempty"` UpdateTime time.Time `json:"updateTime,omitempty"` //日志文件位置 Logger string `json:"logger,omitempty"` }
监控程序
func NewProgram ¶
func NewProgram() *Program
func (*Program) IsForeground ¶
type TailLogger ¶
type TailLogger func(id, line string)
Click to show internal directories.
Click to hide internal directories.