blob: cee962e29bf380ba551bb5352d2546b5074d09f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package _____
import (
"github.com/spiral/roadrunner"
"os/exec"
"strings"
"time"
)
// todo: move out
type PoolConfig struct {
Command string
Relay string
Number uint64
MaxJobs uint64
Timeouts struct {
Construct int
Allocate int
Destroy int
}
}
func (f *PoolConfig) rrConfig() roadrunner.Config {
return roadrunner.Config{
NumWorkers: f.Number,
MaxExecutions: f.MaxJobs,
AllocateTimeout: time.Second * time.Duration(f.Timeouts.Allocate),
DestroyTimeout: time.Second * time.Duration(f.Timeouts.Destroy),
}
}
func (f *PoolConfig) cmd() func() *exec.Cmd {
cmd := strings.Split(f.Command, " ")
return func() *exec.Cmd { return exec.Command(cmd[0], cmd[1:]...) }
}
|