Improve docs
This commit is contained in:
parent
d6f9faae0d
commit
d4c26876d3
3 changed files with 25 additions and 15 deletions
17
lib/util.js
generated
17
lib/util.js
generated
|
|
@ -149,14 +149,19 @@ function getMemoryFlagValueForPlatform(userInput, totalMemoryBytes, platform) {
|
|||
}
|
||||
exports.getMemoryFlagValueForPlatform = getMemoryFlagValueForPlatform;
|
||||
/**
|
||||
* Get the total amount of memory available to the Action.
|
||||
* Get the total amount of memory available to the Action, taking into account constraints imposed
|
||||
* by cgroups on Linux.
|
||||
*/
|
||||
function getTotalMemoryAvailable() {
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory/memory.limit_in_bytes")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory/memory.limit_in_bytes", "utf8"));
|
||||
}
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory.max")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory.max", "utf8"));
|
||||
if (os.platform() === "linux") {
|
||||
// Respect constraints imposed by Linux cgroups v1
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory/memory.limit_in_bytes")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory/memory.limit_in_bytes", "utf8"));
|
||||
}
|
||||
// Respect constraints imposed by Linux cgroups v2
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory.max")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory.max", "utf8"));
|
||||
}
|
||||
}
|
||||
return os.totalmem();
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
21
src/util.ts
21
src/util.ts
|
|
@ -212,16 +212,21 @@ export function getMemoryFlagValueForPlatform(
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the total amount of memory available to the Action.
|
||||
* Get the total amount of memory available to the Action, taking into account constraints imposed
|
||||
* by cgroups on Linux.
|
||||
*/
|
||||
function getTotalMemoryAvailable(): number {
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory/memory.limit_in_bytes")) {
|
||||
return Number(
|
||||
fs.readFileSync("/sys/fs/cgroup/memory/memory.limit_in_bytes", "utf8"),
|
||||
);
|
||||
}
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory.max")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory.max", "utf8"));
|
||||
if (os.platform() === "linux") {
|
||||
// Respect constraints imposed by Linux cgroups v1
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory/memory.limit_in_bytes")) {
|
||||
return Number(
|
||||
fs.readFileSync("/sys/fs/cgroup/memory/memory.limit_in_bytes", "utf8"),
|
||||
);
|
||||
}
|
||||
// Respect constraints imposed by Linux cgroups v2
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory.max")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory.max", "utf8"));
|
||||
}
|
||||
}
|
||||
return os.totalmem();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue