-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b05d5d
commit b4fc91d
Showing
4 changed files
with
67 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import cluster from "node:cluster"; | ||
import render from "./render.js"; | ||
if (!cluster.isWorker) process.exit(1); | ||
const workerId = cluster.worker.id; | ||
|
||
cluster.worker.on("message", async (msg: any) => { | ||
console.log(`Worker ${workerId} received render request (#${msg.workId})`); | ||
let params = msg.data; | ||
let receivedBuffer = await render(params.name, params.width, params.height, params.wh, params.mag, params.blockSize, params.colour) | ||
console.log(`Worker ${workerId} completed render request`); | ||
|
||
cluster.worker.send({ | ||
type: "completed", | ||
workId: msg.workId, | ||
data: receivedBuffer as Buffer | ||
}); | ||
}); | ||
|
||
console.log(`Worker ${workerId} fully initialised`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
rm -rf dist | ||
npx tsc | ||
node . --port 3000 --cache-removal-timer 285000 | ||
node . --port 3000 --cache-removal-timer 285000 --use-cluster true |