mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
refactoring (#116)
- refactoring architecture - fix incomplete ssh logs - code editor for scripts in the app - remove Jobs and SSHCommands
This commit is contained in:
@ -4,8 +4,11 @@
|
||||
|
||||
use App\Enums\SiteStatus;
|
||||
use App\Exceptions\SourceControlIsNotConnected;
|
||||
use App\Facades\Notifier;
|
||||
use App\Models\Server;
|
||||
use App\Models\Site;
|
||||
use App\Notifications\SiteInstallationFailed;
|
||||
use App\Notifications\SiteInstallationSucceed;
|
||||
use App\ValidationRules\DomainRule;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@ -30,11 +33,11 @@ public function create(Server $server, array $input): Site
|
||||
'type' => $input['type'],
|
||||
'domain' => $input['domain'],
|
||||
'aliases' => isset($input['alias']) ? [$input['alias']] : [],
|
||||
'path' => '/home/'.$server->ssh_user.'/'.$input['domain'],
|
||||
'path' => '/home/'.$server->getSshUser().'/'.$input['domain'],
|
||||
'status' => SiteStatus::INSTALLING,
|
||||
]);
|
||||
|
||||
// fields based on type
|
||||
// fields based on the type
|
||||
$site->fill($site->type()->createFields($input));
|
||||
|
||||
// check has access to repository
|
||||
@ -63,8 +66,19 @@ public function create(Server $server, array $input): Site
|
||||
'content' => '',
|
||||
]);
|
||||
|
||||
// install server
|
||||
$site->install();
|
||||
// install site
|
||||
dispatch(function () use ($site) {
|
||||
$site->type()->install();
|
||||
$site->update([
|
||||
'status' => SiteStatus::READY,
|
||||
'progress' => 100,
|
||||
]);
|
||||
Notifier::send($site, new SiteInstallationSucceed($site));
|
||||
})->catch(function () use ($site) {
|
||||
$site->status = SiteStatus::INSTALLATION_FAILED;
|
||||
$site->save();
|
||||
Notifier::send($site, new SiteInstallationFailed($site));
|
||||
})->onConnection('ssh');
|
||||
|
||||
DB::commit();
|
||||
|
||||
@ -105,7 +119,7 @@ private function validateInputs(Server $server, array $input): void
|
||||
*/
|
||||
private function validateType(Site $site, array $input): void
|
||||
{
|
||||
$rules = $site->type()->createValidationRules($input);
|
||||
$rules = $site->type()->createRules($input);
|
||||
|
||||
Validator::make($input, $rules)->validate();
|
||||
}
|
||||
|
Reference in New Issue
Block a user