2021-07-03 07:35:02 +10:00
|
|
|
const fs = from 'fs');
|
|
|
|
const ipc = from '../../node-ipc');
|
2017-07-21 22:18:16 +10:00
|
|
|
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|