-
Notifications
You must be signed in to change notification settings - Fork 192
Expand file tree
/
Copy pathserver.mjs
More file actions
33 lines (29 loc) · 1.02 KB
/
server.mjs
File metadata and controls
33 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env node
import { isMainThread } from 'node:worker_threads';
import { start } from './lib/bridge/src/server.js';
import { createWorker } from './lib/shared/src/helpers/worker.js';
// import containing code which is only executed if it's a child process
import './lib/bridge/src/worker.js';
if (isMainThread) {
/**
* This script expects following arguments
*
* port - port number on which server.mjs should listen
* host - host address on which server.mjs should listen
* debugMemory - print memory usage
* timeoutSeconds - timeout for the node server to wait before shutting down. If not provided or 0,
*/
const port = process.argv[2];
const host = process.argv[3];
const debugMemory = process.argv[4] === 'true';
const timeoutSeconds = Number(process.argv[5]) || 0;
Promise.resolve().then(async () => {
return start(
Number.parseInt(port, 10),
host,
await createWorker(new URL(import.meta.url), { debugMemory }),
debugMemory,
timeoutSeconds,
);
});
}