mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
25 lines
550 B
JavaScript
25 lines
550 B
JavaScript
const net = require('net');
|
|
|
|
module.exports = (config, clustering) => {
|
|
// dummy shutdown if we're not master
|
|
let shutdown = (cb) => { cb(); };
|
|
|
|
clustering.onlyOnMaster(() => {
|
|
const server = net.createServer((socket) => {
|
|
socket.setEncoding('utf8');
|
|
socket.on('data', clustering.send);
|
|
socket.on('end', clustering.send);
|
|
});
|
|
|
|
server.listen(config.port || 5000, config.host || 'localhost', () => {
|
|
server.unref();
|
|
});
|
|
|
|
shutdown = (cb) => {
|
|
server.close(cb);
|
|
};
|
|
});
|
|
|
|
return shutdown;
|
|
};
|