Skip to content

Commit 8599e2c

Browse files
committed
Add server state change events into the console log
1 parent 0108035 commit 8599e2c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

resources/scripts/components/server/Console.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export default () => {
4949
'\u001b[1m\u001b[41m[Internal] ' + line.replace(/(?:\r\n|\r|\n)$/im, '') + '\u001b[0m',
5050
);
5151

52+
const handlePowerChangeEvent = (state: string) => terminal.writeln(
53+
'\u001b[1m\u001b[33m[Status Change] Server marked as ' + state + '...\u001b[0m',
54+
);
55+
5256
const handleCommandKeydown = (e: React.KeyboardEvent<HTMLInputElement>) => {
5357
if (e.key !== 'Enter' || (e.key === 'Enter' && e.currentTarget.value.length < 1)) {
5458
return;
@@ -72,14 +76,16 @@ export default () => {
7276
if (connected && instance) {
7377
terminal.clear();
7478

79+
instance.addListener('status', handlePowerChangeEvent);
7580
instance.addListener('console output', handleConsoleOutput);
7681
instance.addListener('daemon error', handleDaemonErrorOutput);
7782
instance.send('send logs');
7883
}
7984

8085
return () => {
8186
instance && instance.removeListener('console output', handleConsoleOutput)
82-
.removeListener('daemon error', handleDaemonErrorOutput);
87+
.removeListener('daemon error', handleDaemonErrorOutput)
88+
.removeListener('status', handlePowerChangeEvent);
8389
};
8490
}, [ connected, instance ]);
8591

0 commit comments

Comments
 (0)