mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-29 14:24:46 +02:00
Add server state change events into the console log
This commit is contained in:
parent
0108035c05
commit
8599e2c64b
@ -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…
x
Reference in New Issue
Block a user