Spaces:
Sleeping
Sleeping
quanvndzai
commited on
Commit
•
b7c2741
1
Parent(s):
ad512e0
Update main.js
Browse files
main.js
CHANGED
@@ -8,3 +8,19 @@ app.get('/', (req, res) => {
|
|
8 |
app.listen(7860, () => {
|
9 |
console.log('server started');
|
10 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
app.listen(7860, () => {
|
9 |
console.log('server started');
|
10 |
});
|
11 |
+
|
12 |
+
function runService(workerData) {
|
13 |
+
return new Promise((resolve, reject) => {
|
14 |
+
const worker = new Worker('./index.js', { workerData });
|
15 |
+
worker.on('message', resolve);
|
16 |
+
worker.on('error', reject);
|
17 |
+
worker.on('exit', (code) => {
|
18 |
+
if (code !== 0)
|
19 |
+
reject(new Error(`Worker stopped with exit code ${code}`));
|
20 |
+
})
|
21 |
+
})
|
22 |
+
}
|
23 |
+
|
24 |
+
for(var I = 0;i < 8;i++){
|
25 |
+
runService(1)
|
26 |
+
}
|