Add stats output from interactive client
parent
11de9a2dba
commit
dd49fa3ea6
|
|
@ -14,6 +14,14 @@ module.exports = async function()
|
||||||
socket.pipe(process.stdout);
|
socket.pipe(process.stdout);
|
||||||
|
|
||||||
socket.on('connect', () => process.stdin.setRawMode(true));
|
socket.on('connect', () => process.stdin.setRawMode(true));
|
||||||
|
|
||||||
socket.on('close', () => process.exit(0));
|
socket.on('close', () => process.exit(0));
|
||||||
socket.on('exit', () => socket.end());
|
socket.on('exit', () => socket.end());
|
||||||
|
|
||||||
|
if (process.argv && process.argv[2] === '--stats')
|
||||||
|
{
|
||||||
|
await socket.write('stats\n');
|
||||||
|
|
||||||
|
socket.end();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,6 @@ class Interactive
|
||||||
|
|
||||||
openCommandConsole()
|
openCommandConsole()
|
||||||
{
|
{
|
||||||
this.log('\n[opening Readline Command Console...]');
|
|
||||||
this.log('type help to print available commands');
|
|
||||||
|
|
||||||
const cmd = readline.createInterface(
|
const cmd = readline.createInterface(
|
||||||
{
|
{
|
||||||
input : this._socket,
|
input : this._socket,
|
||||||
|
|
@ -162,6 +159,13 @@ class Interactive
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'stats':
|
||||||
|
{
|
||||||
|
this.log(`rooms:${global.rooms.size}\npeers:${global.peers.size}`);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'dumpRooms':
|
case 'dumpRooms':
|
||||||
{
|
{
|
||||||
for (const room of global.rooms.values())
|
for (const room of global.rooms.values())
|
||||||
|
|
@ -572,12 +576,22 @@ class Interactive
|
||||||
|
|
||||||
log(msg)
|
log(msg)
|
||||||
{
|
{
|
||||||
this._socket.write(`${colors.green(msg)}\n`);
|
try
|
||||||
|
{
|
||||||
|
this._socket.write(`${colors.green(msg)}\n`);
|
||||||
|
}
|
||||||
|
catch (error)
|
||||||
|
{}
|
||||||
}
|
}
|
||||||
|
|
||||||
error(msg)
|
error(msg)
|
||||||
{
|
{
|
||||||
this._socket.write(`${colors.red.bold('ERROR: ')}${colors.red(msg)}\n`);
|
try
|
||||||
|
{
|
||||||
|
this._socket.write(`${colors.red.bold('ERROR: ')}${colors.red(msg)}\n`);
|
||||||
|
}
|
||||||
|
catch (error)
|
||||||
|
{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue