|
|
|
@ -216,6 +216,11 @@ func (c *Cmd) Status() Status {
|
|
|
|
|
return c.status
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// StatusChan 返回状态channel
|
|
|
|
|
func (c *Cmd) StatusChan() <-chan Status {
|
|
|
|
|
return c.statusChan
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Done 返回一个在Cmd停止运行时关闭的通道。
|
|
|
|
|
// 等待所有的 goroutine 完成执行
|
|
|
|
|
// 命令完成后调用 Status 来获取其最终状态
|
|
|
|
@ -223,6 +228,22 @@ func (c *Cmd) Done() <-chan struct{} {
|
|
|
|
|
return c.doneChan
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Started 命令是否正常运行
|
|
|
|
|
func (c *Cmd) Started() bool {
|
|
|
|
|
c.Lock()
|
|
|
|
|
defer c.Unlock()
|
|
|
|
|
|
|
|
|
|
return c.started
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Stopped 命令是否已停止
|
|
|
|
|
func (c *Cmd) Stopped() bool {
|
|
|
|
|
c.Lock()
|
|
|
|
|
defer c.Unlock()
|
|
|
|
|
|
|
|
|
|
return c.stopped
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *Cmd) run() {
|
|
|
|
|
defer func() {
|
|
|
|
|
c.statusChan <- c.Status()
|
|
|
|
|