Adjust process state if parser doesn't indicate that the process is producing output

This commit is contained in:
Ingo Oppermann
2024-04-15 16:43:34 +02:00
parent 197d3bb611
commit b851249b98
4 changed files with 22 additions and 2 deletions

View File

@@ -660,6 +660,13 @@ func (p *parser) Progress() Progress {
return 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 { func (p *parser) Prelude() []string {
p.lock.prelude.RLock() p.lock.prelude.RLock()
if p.prelude.data == nil { if p.prelude.data == nil {

View File

@@ -141,3 +141,7 @@ func (p *prober) ResetLog() {
p.data = []process.Line{} p.data = []process.Line{}
p.inputs = []probeIO{} p.inputs = []probeIO{}
} }
func (p *prober) IsRunning() bool {
return true
}

View File

@@ -26,8 +26,11 @@ type Parser interface {
// before the process starts. // before the process starts.
ResetLog() ResetLog()
// Log returns a slice of collected log lines // Log returns a slice of collected log lines.
Log() []Line Log() []Line
// IsRunning returns whether the process is producing output.
IsRunning() bool
} }
// Line represents a line from the output with its timestamp. The // 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) ResetStats() {}
func (p *nullParser) ResetLog() {} func (p *nullParser) ResetLog() {}
func (p *nullParser) Log() []Line { return []Line{} } func (p *nullParser) Log() []Line { return []Line{} }
func (p *nullParser) IsRunning() bool { return true }
type bufferParser struct { type bufferParser struct {
log []Line log []Line
@@ -77,4 +81,5 @@ func (p *bufferParser) ResetStats() {}
func (p *bufferParser) ResetLog() { func (p *bufferParser) ResetLog() {
p.log = []Line{} p.log = []Line{}
} }
func (p *bufferParser) Log() []Line { return p.log } func (p *bufferParser) Log() []Line { return p.log }
func (p *bufferParser) IsRunning() bool { return true }

View File

@@ -454,6 +454,10 @@ func (p *process) Status() Status {
states := p.state.states states := p.state.states
p.state.lock.Unlock() p.state.lock.Unlock()
if state == stateRunning && !p.parser.IsRunning() {
state = stateStarting
}
order := p.getOrder() order := p.getOrder()
s := Status{ s := Status{