Implement basic queue, where is it impossible to run two identical job
in parallel
This commit is contained in:
parent
8259aaa474
commit
af96f82831
4 changed files with 81 additions and 4 deletions
10
jobs.go
10
jobs.go
|
|
@ -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,
|
||||
|
|
|
|||
Reference in a new issue