You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
582 B
32 lines
582 B
4 years ago
|
const fs = require('fs');
|
||
|
const ipc = require('../../node-ipc');
|
||
|
|
||
|
const socketPath = '/tmp/ipc.sock';
|
||
|
|
||
|
//loop forever so you can see the pid of the cluster sever change in the logs
|
||
|
setInterval(
|
||
|
function() {
|
||
|
ipc.connectTo(
|
||
|
'world',
|
||
|
socketPath,
|
||
|
connecting
|
||
|
);
|
||
|
},
|
||
|
2000
|
||
|
);
|
||
|
|
||
|
function connecting(socket) {
|
||
|
ipc.of.world.on(
|
||
|
'connect',
|
||
|
function() {
|
||
|
ipc.of.world.emit(
|
||
|
'currentDate',
|
||
|
{
|
||
|
message: new Date().toISOString()
|
||
|
}
|
||
|
);
|
||
|
ipc.disconnect('world');
|
||
|
}
|
||
|
);
|
||
|
}
|