Add server state change events into the console log
This commit is contained in:
parent
0108035c05
commit
8599e2c64b
1 changed files with 7 additions and 1 deletions
|
@ -49,6 +49,10 @@ export default () => {
|
||||||
'\u001b[1m\u001b[41m[Internal] ' + line.replace(/(?:\r\n|\r|\n)$/im, '') + '\u001b[0m',
|
'\u001b[1m\u001b[41m[Internal] ' + line.replace(/(?:\r\n|\r|\n)$/im, '') + '\u001b[0m',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handlePowerChangeEvent = (state: string) => terminal.writeln(
|
||||||
|
'\u001b[1m\u001b[33m[Status Change] Server marked as ' + state + '...\u001b[0m',
|
||||||
|
);
|
||||||
|
|
||||||
const handleCommandKeydown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
const handleCommandKeydown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
if (e.key !== 'Enter' || (e.key === 'Enter' && e.currentTarget.value.length < 1)) {
|
if (e.key !== 'Enter' || (e.key === 'Enter' && e.currentTarget.value.length < 1)) {
|
||||||
return;
|
return;
|
||||||
|
@ -72,6 +76,7 @@ export default () => {
|
||||||
if (connected && instance) {
|
if (connected && instance) {
|
||||||
terminal.clear();
|
terminal.clear();
|
||||||
|
|
||||||
|
instance.addListener('status', handlePowerChangeEvent);
|
||||||
instance.addListener('console output', handleConsoleOutput);
|
instance.addListener('console output', handleConsoleOutput);
|
||||||
instance.addListener('daemon error', handleDaemonErrorOutput);
|
instance.addListener('daemon error', handleDaemonErrorOutput);
|
||||||
instance.send('send logs');
|
instance.send('send logs');
|
||||||
|
@ -79,7 +84,8 @@ export default () => {
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
instance && instance.removeListener('console output', handleConsoleOutput)
|
instance && instance.removeListener('console output', handleConsoleOutput)
|
||||||
.removeListener('daemon error', handleDaemonErrorOutput);
|
.removeListener('daemon error', handleDaemonErrorOutput)
|
||||||
|
.removeListener('status', handlePowerChangeEvent);
|
||||||
};
|
};
|
||||||
}, [ connected, instance ]);
|
}, [ connected, instance ]);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue