Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/components/c2d/compute_engine_docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,32 +208,45 @@ export class C2DEngineDocker extends C2DEngine {
if (`maxJobs` in envConfig) this.envs[0].maxJobs = envConfig.maxJobs
// let's add resources
this.envs[0].resources = []
this.envs[0].resources.push({
const cpuResources = {
id: 'cpu',
type: 'cpu',
total: sysinfo.NCPU,
max: sysinfo.NCPU,
min: 1,
description: os.cpus()[0].model
})
this.envs[0].resources.push({
}
const ramResources = {
id: 'ram',
type: 'ram',
total: Math.floor(sysinfo.MemTotal / 1024 / 1024 / 1024),
max: Math.floor(sysinfo.MemTotal / 1024 / 1024 / 1024),
min: 1
})
}

if (envConfig.resources) {
for (const res of envConfig.resources) {
// allow user to add other resources
if (res.id === 'cpu') {
if (res.total) cpuResources.total = res.total
if (res.max) cpuResources.max = res.max
if (res.min) cpuResources.min = res.min
}
if (res.id === 'ram') {
if (res.total) ramResources.total = res.total
if (res.max) ramResources.max = res.max
if (res.min) ramResources.min = res.min
}

if (res.id !== 'cpu' && res.id !== 'ram') {
if (!res.max) res.max = res.total
if (!res.min) res.min = 0
this.envs[0].resources.push(res)
}
}
}
this.envs[0].resources.push(cpuResources)
this.envs[0].resources.push(ramResources)
/* TODO - get namedresources & discreete one
if (sysinfo.GenericResources) {
for (const [key, value] of Object.entries(sysinfo.GenericResources)) {
Expand Down
Loading