From 8a3138659b3e43b789bad0ad5e4c2ced27aa0224 Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Mon, 29 Apr 2024 13:06:39 +0300 Subject: [PATCH] update --- web/Modules/Terminal/Filament/Pages/Terminal.php | 10 +++++++++- web/Modules/Terminal/nodejs/terminal/server.js | 14 ++++++++++---- .../Terminal/shell-scripts/install-nodejs.sh | 2 +- .../Components/QuickServiceRestartMenu.php | 5 +++++ .../filament/quick-service-restart-menu.blade.php | 12 ++++++++++++ 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/web/Modules/Terminal/Filament/Pages/Terminal.php b/web/Modules/Terminal/Filament/Pages/Terminal.php index 5b9eda6..90c3cc3 100644 --- a/web/Modules/Terminal/Filament/Pages/Terminal.php +++ b/web/Modules/Terminal/Filament/Pages/Terminal.php @@ -30,8 +30,16 @@ class Terminal extends Page shell_exec('mkdir -p ' . dirname($appTerminalConfigFile)); } + $serverIps = []; + $serverIps[] = $serverIp; + + $masterDomain = setting('general.master_domain'); + if (!empty($masterDomain)) { + $serverIps[] = $masterDomain; + } + file_put_contents($appTerminalConfigFile, json_encode([ - 'serverIp' => $serverIp, + 'serverIps' => $serverIps, ], JSON_PRETTY_PRINT)); $appTerminalSessionsPath = storage_path('app/terminal/sessions'); diff --git a/web/Modules/Terminal/nodejs/terminal/server.js b/web/Modules/Terminal/nodejs/terminal/server.js index c58035f..1d7f544 100644 --- a/web/Modules/Terminal/nodejs/terminal/server.js +++ b/web/Modules/Terminal/nodejs/terminal/server.js @@ -10,7 +10,11 @@ const hostname = execSync('hostname', { silent: true }).toString().trim(); const systemIPs = []; const terminalConfig = JSON.parse(readFileSync("/usr/local/phyre/web/storage/app/terminal/config.json").toString()); -systemIPs.push(terminalConfig.serverIp); +if (terminalConfig.serverIps) { + for (const ip of terminalConfig.serverIps) { + systemIPs.push(ip); + } +} const config = { WEB_TERMINAL_PORT: 8449, @@ -145,9 +149,11 @@ wss.on('connection', (ws, req) => { // Ensure pty is killed when websocket is closed and vice versa pty.on('exit', () => { console.log(`Ended pty (${pty.pid})`); - if (ws.OPEN) { - ws.close(); - } + // if (ws.OPEN) { + // ws.close(); + // } + pty.kill(); + wss.clients.delete(ws); }); ws.on('close', () => { console.log(`Ended connection from ${remoteIP} (${sessionID})`); diff --git a/web/Modules/Terminal/shell-scripts/install-nodejs.sh b/web/Modules/Terminal/shell-scripts/install-nodejs.sh index 86bb487..ed51beb 100644 --- a/web/Modules/Terminal/shell-scripts/install-nodejs.sh +++ b/web/Modules/Terminal/shell-scripts/install-nodejs.sh @@ -1,4 +1,4 @@ -sudo apt-get install npm nodejs -y +sudo apt-get install net-tools npm nodejs -y cd /usr/local/phyre/web/Modules/Terminal/nodejs/terminal npm i diff --git a/web/app/Livewire/Components/QuickServiceRestartMenu.php b/web/app/Livewire/Components/QuickServiceRestartMenu.php index 4e6d3d4..9ac73e8 100644 --- a/web/app/Livewire/Components/QuickServiceRestartMenu.php +++ b/web/app/Livewire/Components/QuickServiceRestartMenu.php @@ -35,6 +35,11 @@ class QuickServiceRestartMenu extends Component implements HasForms, HasActions shell_exec('sudo service mysql restart'); } + public function restartPhyreServices() + { + shell_exec('sudo service phyre restart'); + } + public function render(): View { return view('filament.quick-service-restart-menu'); diff --git a/web/resources/views/filament/quick-service-restart-menu.blade.php b/web/resources/views/filament/quick-service-restart-menu.blade.php index ce857ae..71b9468 100644 --- a/web/resources/views/filament/quick-service-restart-menu.blade.php +++ b/web/resources/views/filament/quick-service-restart-menu.blade.php @@ -125,6 +125,18 @@ + +
+ + + + + + + Restart Phyre Services +
+
+