This commit is contained in:
Bozhidar 2024-04-29 13:06:39 +03:00
parent c75cf6f1eb
commit 8a3138659b
5 changed files with 37 additions and 6 deletions

View file

@ -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');

View file

@ -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})`);

View file

@ -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

View file

@ -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');

View file

@ -125,6 +125,18 @@
</div>
</x-filament::dropdown.list.item>
<x-filament::dropdown.list.item wire:key="restart-phyre-services" wire:click="restartPhyreServices" tag="button">
<div class="flex items-center gap-2">
<svg xmlns="http://www.w3.org/2000/svg" class="text-primary-500 w-6" viewBox="0 0 24 24">
<g fill="none">
<path d="M24 0v24H0V0zM12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035c-.01-.004-.019-.001-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427c-.002-.01-.009-.017-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093c.012.004.023 0 .029-.008l.004-.014l-.034-.614c-.003-.012-.01-.02-.02-.022m-.715.002a.023.023 0 0 0-.027.006l-.006.014l-.034.614c0 .012.007.02.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z" />
<path fill="currentColor" d="m11.514 2.142l-1.26-.755l-.24 1.449C9.632 5.124 8.069 7.25 6.345 8.744C2.97 11.67 2.231 14.85 3.276 17.475c1 2.512 3.538 4.232 6.114 4.519l.596.066c-1.474-.901-2.42-3.006-2.09-4.579c.326-1.546 1.438-2.994 3.574-4.33l1.077-.672l.402 1.205c.237.712.647 1.284 1.064 1.865c.2.28.403.563.589.864c.643 1.045.813 2.207.398 3.36c-.378 1.048-1.001 1.872-1.86 2.329l.97-.108c2.418-.269 4.193-1.096 5.346-2.479C20.599 18.144 21 16.379 21 14.5c0-1.75-.719-3.554-1.567-5.055c-.994-1.758-2.291-3.218-3.707-4.633c-.245.49-.226.688-.73 1.475a8.146 8.146 0 0 0-3.482-4.145" />
</g>
</svg>
Restart Phyre Services
</div>
</x-filament::dropdown.list.item>
</x-filament::dropdown.list>
</x-filament::dropdown>