Files: 1eb144e388da5f1a3466703f56ac4ab591d700fc / test / test-50-spawn / test-cluster.js
492 bytesRaw
1 | |
2 | |
3 | 'use strict'; |
4 | |
5 | var assert = require('assert'); |
6 | var cluster = require('cluster'); |
7 | var child; |
8 | |
9 | if (process.send) { |
10 | require('./test-cluster-child.js'); |
11 | return; |
12 | } |
13 | |
14 | assert(cluster.isMaster); |
15 | |
16 | try { |
17 | child = cluster.fork(); |
18 | } catch (e) { |
19 | console.log(e.message); |
20 | } |
21 | |
22 | child.on('message', function (value) { |
23 | console.log(value.toString()); |
24 | child.send(value); |
25 | }); |
26 | |
27 | child.send(2); |
28 | |
29 | cluster.on('exit', function (_, code) { |
30 | console.log('Child exited with code', code); |
31 | }); |
32 |
Built with git-ssb-web