Documentation ¶
Overview ¶
Like python-supervisor Manager process start, stop, restart Hope no bugs :)
Index ¶
- Variables
- func KillProcessByMatchName(processNameMatch string) bool
- func KillProcessByName(processName string) bool
- type CommandCtrl
- func (cc *CommandCtrl) Add(name string, c CommandInfo) error
- func (cc *CommandCtrl) Exists(name string) bool
- func (cc *CommandCtrl) Restart(name string) error
- func (cc *CommandCtrl) Running(name string) bool
- func (cc *CommandCtrl) Start(name string) error
- func (cc *CommandCtrl) Stop(name string, waits ...bool) error
- func (cc *CommandCtrl) StopAll()
- func (cc *CommandCtrl) UpdateArgs(name string, args ...string) error
- type CommandInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAlreadyRunning = errors.New("already running") ErrAlreadyStopped = errors.New("already stopped") )
Functions ¶
func KillProcessByMatchName ¶
根据进程名模糊匹配,杀死进程
Types ¶
type CommandCtrl ¶
type CommandCtrl struct {
// contains filtered or unexported fields
}
func New ¶
func New() *CommandCtrl
func (*CommandCtrl) Add ¶
func (cc *CommandCtrl) Add(name string, c CommandInfo) error
func (*CommandCtrl) Exists ¶
func (cc *CommandCtrl) Exists(name string) bool
func (*CommandCtrl) Restart ¶
func (cc *CommandCtrl) Restart(name string) error
func (*CommandCtrl) Running ¶
func (cc *CommandCtrl) Running(name string) bool
Running return bool indicate if program is still running
func (*CommandCtrl) Start ¶
func (cc *CommandCtrl) Start(name string) error
func (*CommandCtrl) Stop ¶
func (cc *CommandCtrl) Stop(name string, waits ...bool) error
Stop send stop signal Stop("demo") will quit immediately Stop("demo", true) will quit until command really killed
func (*CommandCtrl) StopAll ¶
func (cc *CommandCtrl) StopAll()
StopAll command and wait until all program quited
func (*CommandCtrl) UpdateArgs ¶
func (cc *CommandCtrl) UpdateArgs(name string, args ...string) error
UpdateArgs func is not like exec.Command, the first argument name means cmdctl service name the seconds argument args, should like "echo", "hello" Example usage:
UpdateArgs("minitouch", "/data/local/tmp/minitouch", "-t", "1")
type CommandInfo ¶
type CommandInfo struct { Environ []string Args []string ArgsFunc func() ([]string, error) // generate Args when args is dynamic MaxRetries int // 3 NextLaunchWait time.Duration // 0.5s RecoverDuration time.Duration // 30s StopSignal os.Signal Shell bool OnStart func() error // if return non nil, cmd will not run OnStop func() Stderr io.Writer // nil Stdout io.Writer // nil Stdin io.Reader // nil }
Click to show internal directories.
Click to hide internal directories.