node-ipc/example/clusterUnixSocket/cluster-client.js

32 lines
543 B
JavaScript
Raw Normal View History

2021-07-08 06:10:40 +10:00
import fs from 'fs';
import ipc from '../../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');
}
);
}