refactoring (#116)

- refactoring architecture
- fix incomplete ssh logs
- code editor for scripts in the app
- remove Jobs and SSHCommands
This commit is contained in:
Saeed Vaziry
2024-03-14 20:03:43 +01:00
committed by GitHub
parent cee4a70c3c
commit 428140b931
472 changed files with 24110 additions and 8159 deletions

View File

@ -3,7 +3,6 @@
namespace App\Actions\PHP;
use App\Models\Server;
use App\SSHCommands\PHP\GetPHPIniCommand;
use Illuminate\Validation\ValidationException;
class GetPHPIni
@ -12,8 +11,10 @@ public function getIni(Server $server, array $input): string
{
$this->validate($server, $input);
$php = $server->php($input['version']);
try {
return $server->ssh()->exec(new GetPHPIniCommand($input['version']));
return $php->handler()->getPHPIni();
} catch (\Throwable $e) {
throw ValidationException::withMessages(
['ini' => $e->getMessage()]

View File

@ -28,7 +28,14 @@ public function install(Server $server, array $input): void
'is_default' => false,
]);
$php->save();
$php->install();
dispatch(function () use ($php) {
$php->handler()->install();
$php->status = ServiceStatus::READY;
$php->save();
})->catch(function () use ($php) {
$php->delete();
})->onConnection('ssh');
}
/**

View File

@ -10,9 +10,6 @@
class InstallPHPExtension
{
/**
* @throws ValidationException
*/
public function install(Server $server, array $input): Service
{
$this->validate($server, $input);
@ -21,10 +18,19 @@ public function install(Server $server, array $input): Service
$service = $server->php($input['version']);
$typeData = $service->type_data;
$typeData['extensions'] = $typeData['extensions'] ?? [];
$typeData['extensions'][] = $input['extension'];
$service->type_data = $typeData;
$service->save();
$service->handler()->installExtension($input['extension']);
dispatch(function () use ($service, $input) {
$service->handler()->installExtension($input['extension']);
})->catch(function () use ($service, $input) {
$service->refresh();
$typeData = $service->type_data;
$typeData['extensions'] = array_values(array_diff($typeData['extensions'], [$input['extension']]));
$service->type_data = $typeData;
$service->save();
})->onConnection('ssh');
return $service;
}

View File

@ -2,6 +2,7 @@
namespace App\Actions\PHP;
use App\Enums\ServiceStatus;
use App\Models\Server;
use App\Models\Service;
use Illuminate\Support\Facades\Validator;
@ -15,8 +16,16 @@ public function uninstall(Server $server, array $input): void
/** @var Service $php */
$php = $server->php($input['version']);
$php->status = ServiceStatus::UNINSTALLING;
$php->save();
$php->uninstall();
dispatch(function () use ($php) {
$php->handler()->uninstall();
$php->delete();
})->catch(function () use ($php) {
$php->status = ServiceStatus::FAILED;
$php->save();
})->onConnection('ssh');
}
/**