Browse Source

En cours de développement

master
losyme 4 months ago
parent
commit
5a4108a662
  1. 22
      workers/worker.go

22
workers/worker.go

@ -9,6 +9,7 @@ package workers
import (
"context"
"fmt"
"runtime/debug"
"time"
"forge.chapril.org/dune/jw"
@ -69,6 +70,25 @@ func (w *worker) updateJob(job *jw.Job) {
}
}
func (w *worker) runJob(job *jw.Job) {
defer func() {
if data := recover(); data != nil {
if w.logger != nil {
w.logger.Error( //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"PANIC ERROR RECOVERED",
"job", job.ID,
"data", data,
"stack", string(debug.Stack()),
)
}
job.Failed().SetError(fmt.Sprintf("PANIC ERROR RECOVERED: %v", data))
}
}()
w.runner.Run(job)
}
func (w *worker) maybeRunJob() time.Duration {
job, err := w.model.NextJob(w.runner.Namespace())
if err != nil {
@ -92,7 +112,7 @@ func (w *worker) maybeRunJob() time.Duration {
)
}
w.runner.Run(job)
w.runJob(job)
w.updateJob(job)
return 0

Loading…
Cancel
Save