mirror of
https://github.com/datarhei/core.git
synced 2025-10-06 08:27:08 +08:00
Adjust process state if parser doesn't indicate that the process is producing output
This commit is contained in:
@@ -660,6 +660,13 @@ func (p *parser) Progress() Progress {
|
||||
return progress
|
||||
}
|
||||
|
||||
func (p *parser) IsRunning() bool {
|
||||
p.lock.progress.RLock()
|
||||
defer p.lock.progress.RUnlock()
|
||||
|
||||
return p.stats.initialized
|
||||
}
|
||||
|
||||
func (p *parser) Prelude() []string {
|
||||
p.lock.prelude.RLock()
|
||||
if p.prelude.data == nil {
|
||||
|
@@ -141,3 +141,7 @@ func (p *prober) ResetLog() {
|
||||
p.data = []process.Line{}
|
||||
p.inputs = []probeIO{}
|
||||
}
|
||||
|
||||
func (p *prober) IsRunning() bool {
|
||||
return true
|
||||
}
|
||||
|
@@ -26,8 +26,11 @@ type Parser interface {
|
||||
// before the process starts.
|
||||
ResetLog()
|
||||
|
||||
// Log returns a slice of collected log lines
|
||||
// Log returns a slice of collected log lines.
|
||||
Log() []Line
|
||||
|
||||
// IsRunning returns whether the process is producing output.
|
||||
IsRunning() bool
|
||||
}
|
||||
|
||||
// Line represents a line from the output with its timestamp. The
|
||||
@@ -52,6 +55,7 @@ func (p *nullParser) Stop(string, Usage) {}
|
||||
func (p *nullParser) ResetStats() {}
|
||||
func (p *nullParser) ResetLog() {}
|
||||
func (p *nullParser) Log() []Line { return []Line{} }
|
||||
func (p *nullParser) IsRunning() bool { return true }
|
||||
|
||||
type bufferParser struct {
|
||||
log []Line
|
||||
@@ -78,3 +82,4 @@ func (p *bufferParser) ResetLog() {
|
||||
p.log = []Line{}
|
||||
}
|
||||
func (p *bufferParser) Log() []Line { return p.log }
|
||||
func (p *bufferParser) IsRunning() bool { return true }
|
||||
|
@@ -454,6 +454,10 @@ func (p *process) Status() Status {
|
||||
states := p.state.states
|
||||
p.state.lock.Unlock()
|
||||
|
||||
if state == stateRunning && !p.parser.IsRunning() {
|
||||
state = stateStarting
|
||||
}
|
||||
|
||||
order := p.getOrder()
|
||||
|
||||
s := Status{
|
||||
|
Reference in New Issue
Block a user