From 51ad40a869ca881918fe1c811519850700b4c9f7 Mon Sep 17 00:00:00 2001 From: criyle Date: Wed, 4 Mar 2020 23:27:55 -0500 Subject: [PATCH] CPU limit s -> ns --- README.md | 10 +++++----- cmd/executorserver/model.go | 8 ++++---- cmd/executorserver/worker.go | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b4df6ac..fa3d2f7 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,8 @@ interface Cmd { files?: (LocalFile | MemoryFile | PreparedFile | Pipe | null)[]; // limitations - cpuLimit?: number; // s - realCpuLimit?: number; // s + cpuLimit?: number; // ns + realCpuLimit?: number; // ns memoryLimit?: number; // byte procLimit?: number; @@ -141,7 +141,7 @@ Single (Require `apt install g++` inside the container): "name": "stderr", "max": 10240 }], - "cpuLimit": 10, + "cpuLimit": 10000000000, "memoryLimit": 104857600, "procLimit": 50, "copyIn": { @@ -186,7 +186,7 @@ Multiple: "name": "stderr", "max": 10240 }], - "cpuLimit": 1, + "cpuLimit": 1000000000, "memoryLimit": 1048576, "procLimit": 50, "copyIn": { @@ -204,7 +204,7 @@ Multiple: "name": "stderr", "max": 10240 }], - "cpuLimit": 1, + "cpuLimit": 1000000000, "memoryLimit": 1048576, "procLimit": 50, "copyOut": ["stdout", "stderr"] diff --git a/cmd/executorserver/model.go b/cmd/executorserver/model.go index 0fc88aa..b1909c6 100644 --- a/cmd/executorserver/model.go +++ b/cmd/executorserver/model.go @@ -15,10 +15,10 @@ type cmd struct { Env []string `json:"env,omitempty"` Files []*cmdFile `json:"files,omitempty"` - CPULimit float64 `json:"cpuLimit"` - RealCPULimit float64 `json:"realCpuLimit"` - MemoryLimit uint64 `json:"memoryLimit"` - ProcLimit uint64 `json:"procLimit"` + CPULimit uint64 `json:"cpuLimit"` + RealCPULimit uint64 `json:"realCpuLimit"` + MemoryLimit uint64 `json:"memoryLimit"` + ProcLimit uint64 `json:"procLimit"` CopyIn map[string]cmdFile `json:"copyIn"` diff --git a/cmd/executorserver/worker.go b/cmd/executorserver/worker.go index 27e4eae..efc6339 100644 --- a/cmd/executorserver/worker.go +++ b/cmd/executorserver/worker.go @@ -189,8 +189,8 @@ func prepareCmd(rc cmd) (*envexec.Cmd, map[string]bool, error) { } w := &waiter{ - timeLimit: time.Duration(rc.CPULimit * float64(time.Second)), - realTimeLimit: time.Duration(rc.RealCPULimit * float64(time.Second)), + timeLimit: time.Duration(rc.CPULimit), + realTimeLimit: time.Duration(rc.RealCPULimit), } return &envexec.Cmd{