add stopping status

master
codeskyblue 8 years ago
parent 771e094fb8
commit f00268de0f

@ -88,11 +88,13 @@ func NewFSM(initState FSMState) *FSM {
}
// Only 4 states now is enough, I think
// 2016-09-18 now five
var (
Running = FSMState("running")
Stopped = FSMState("stopped")
Fatal = FSMState("fatal")
RetryWait = FSMState("retry wait")
Stopping = FSMState("stopping")
StartEvent = FSMEvent("start")
StopEvent = FSMEvent("stop")
@ -217,9 +219,11 @@ func (p *Process) waitNextRetry() {
func (p *Process) stopCommand() {
p.mu.Lock()
defer p.mu.Unlock()
defer p.SetState(Stopped)
if p.cmd == nil {
return
}
p.SetState(Stopping)
if p.cmd.Process != nil {
p.cmd.Process.Signal(syscall.SIGTERM) // TODO(ssx): add it to config
}
@ -242,7 +246,6 @@ func (p *Process) stopCommand() {
p.OutputFile = nil
}
p.cmd = nil
p.SetState(Stopped)
}
func (p *Process) IsRunning() bool {

@ -72,7 +72,7 @@
<td v-text="p.program.name"></td>
<td v-html="p.status | colorStatus"></td>
<td>
<button v-on:click="cmdStart(p.program.name)" class="btn btn-default btn-xs" :disabled="p.status=='running'">
<button v-on:click="cmdStart(p.program.name)" class="btn btn-default btn-xs" :disabled='["running", "stopping"].indexOf(p.status) != -1'>
<span class="glyphicon glyphicon-play"></span> Start
</button>
<button class="btn btn-default btn-xs" v-on:click="cmdStop(p.program.name)" :disabled="!canStop(p.status)">

@ -159,10 +159,12 @@ Vue.filter('colorStatus', function(value) {
return "<span class='status' style='background-color:" + color + "'>" + text + "</span>";
}
switch (value) {
case "stopping":
return makeColorText(value, "#996633");
case "running":
return makeColorText("running", "green");
return makeColorText(value, "green");
case "fatal":
return makeColorText("fatal", "red");
return makeColorText(value, "red");
default:
return makeColorText(value, "gray");
}

Loading…
Cancel
Save