Add pause resume and abort controls
This commit is contained in:
+20
-1
@@ -37,7 +37,7 @@ func (q *Queue) RestoreHistory(runs []model.Run) {
|
||||
q.mu.Lock()
|
||||
defer q.mu.Unlock()
|
||||
for _, run := range runs {
|
||||
if run.Status == "queued" || run.Status == "running" {
|
||||
if run.Status == "queued" || run.Status == "running" || run.Status == "paused" {
|
||||
run.Status = "failed"
|
||||
run.ErrorCode = "environment"
|
||||
run.Message = "daemon restarted while task was active"
|
||||
@@ -125,6 +125,25 @@ func (q *Queue) Cancel(id string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (q *Queue) SetPaused(id string, paused bool) bool {
|
||||
q.mu.Lock()
|
||||
defer q.mu.Unlock()
|
||||
if q.active == nil || q.active.ID != id {
|
||||
return false
|
||||
}
|
||||
expected := "running"
|
||||
next := "paused"
|
||||
if !paused {
|
||||
expected, next = "paused", "running"
|
||||
}
|
||||
if q.active.Status != expected {
|
||||
return false
|
||||
}
|
||||
q.active.Status = next
|
||||
q.emitLocked()
|
||||
return true
|
||||
}
|
||||
|
||||
func (q *Queue) Stop() {
|
||||
q.mu.Lock()
|
||||
q.stopping = true
|
||||
|
||||
Reference in New Issue
Block a user