mirror of
https://github.com/ncarlier/webhookd.git
synced 2024-09-20 00:45:29 +00:00
parent
0c41f76f53
commit
8f8e69faae
|
@ -242,9 +242,17 @@ func (job *Job) Run() error {
|
||||||
|
|
||||||
// Write script output to log file and the work message channel
|
// Write script output to log file and the work message channel
|
||||||
go func(reader io.Reader) {
|
go func(reader io.Reader) {
|
||||||
scanner := bufio.NewScanner(reader)
|
r := bufio.NewReader(reader)
|
||||||
for scanner.Scan() {
|
for {
|
||||||
line := scanner.Text()
|
line, err := r.ReadString('\n')
|
||||||
|
if err != nil {
|
||||||
|
if err == io.EOF {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
slog.Error("error while reading hook std[out/err]", "hook", job.name, "id", job.id, "err", err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
line, _ = strings.CutSuffix(line, "\r")
|
||||||
// writing to the work channel
|
// writing to the work channel
|
||||||
if !job.IsTerminated() {
|
if !job.IsTerminated() {
|
||||||
job.MessageChan <- []byte(line)
|
job.MessageChan <- []byte(line)
|
||||||
|
@ -266,9 +274,6 @@ func (job *Job) Run() error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := scanner.Err(); err != nil {
|
|
||||||
slog.Error("hook is unable to read script stdout", "hook", job.name, "id", job.id, "err", err)
|
|
||||||
}
|
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}(cmdReader)
|
}(cmdReader)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user