Implement basic queue, where is it impossible to run two identical job

in parallel
This commit is contained in:
nemunaire 2021-05-09 19:18:48 +02:00
commit af96f82831
4 changed files with 81 additions and 4 deletions

10
jobs.go
View file

@ -1,6 +1,8 @@
package main
import (
"fmt"
"github.com/docker/docker/api/types/mount"
"github.com/nemunaire/minifaas/engine/docker"
@ -42,6 +44,14 @@ func RunJob(jobtype string) (string, error) {
}
}
n, err := CountRunningContainers(jobtype)
if err != nil {
return "", err
}
if n > 0 {
return "", fmt.Errorf("Please wait, there is already a similar job running.")
}
return docker.Run(
jobtype,
jobs[jobtype].Image,