Skip to content

Commit

Permalink
Add memory restart
Browse files Browse the repository at this point in the history
  • Loading branch information
pastelsky committed Jan 3, 2024
1 parent 2fc6308 commit ced21dc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions server/workers/docs-builder-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ setInterval(() => {

throw new Error("Worker exited because it was jobless for too long.");
}

const gbInBytes = 1024 * 1024 * 1024;

if (process.memoryUsage.rss() > gbInBytes) {
console.log(
"Worker memory usage is too high, exiting...",
process.pid,
" alive for ",
process.uptime(),
"s. Memory usage ",
process.memoryUsage.rss(),
" bytes",
);

throw new Error("Worker exited because it was taking up too much memory.");
}
}, 5000);

function promiseTimeout(promise, ms = 10000) {
Expand Down

0 comments on commit ced21dc

Please sign in to comment.