mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
deploy Wordpress sites via VitoDeploy (#83)
This commit is contained in:
@ -57,19 +57,19 @@ public function server(): BelongsTo
|
||||
/**
|
||||
* create database on server
|
||||
*/
|
||||
public function createOnServer(): void
|
||||
public function createOnServer(string $queue = 'ssh'): void
|
||||
{
|
||||
dispatch(new CreateOnServer($this))->onConnection('ssh');
|
||||
dispatch(new CreateOnServer($this))->onConnection($queue);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete database from server
|
||||
*/
|
||||
public function deleteFromServer(): void
|
||||
public function deleteFromServer(string $queue = 'ssh'): void
|
||||
{
|
||||
$this->status = DatabaseStatus::DELETING;
|
||||
$this->save();
|
||||
dispatch(new DeleteFromServer($this))->onConnection('ssh');
|
||||
dispatch(new DeleteFromServer($this))->onConnection($queue);
|
||||
}
|
||||
|
||||
public function backups(): HasMany
|
||||
|
@ -54,17 +54,17 @@ public function scopeHasDatabase(Builder $query, string $databaseName): Builder
|
||||
return $query->where('databases', 'like', "%\"$databaseName\"%");
|
||||
}
|
||||
|
||||
public function createOnServer(): void
|
||||
public function createOnServer(string $queue = 'ssh'): void
|
||||
{
|
||||
dispatch(new CreateOnServer($this))->onConnection('ssh');
|
||||
dispatch(new CreateOnServer($this))->onConnection($queue);
|
||||
}
|
||||
|
||||
public function deleteFromServer(): void
|
||||
public function deleteFromServer(string $queue = 'ssh'): void
|
||||
{
|
||||
$this->status = DatabaseStatus::DELETING;
|
||||
$this->save();
|
||||
|
||||
dispatch(new DeleteFromServer($this))->onConnection('ssh');
|
||||
dispatch(new DeleteFromServer($this))->onConnection($queue);
|
||||
}
|
||||
|
||||
public function linkNewDatabase(string $name): void
|
||||
@ -79,14 +79,14 @@ public function linkNewDatabase(string $name): void
|
||||
}
|
||||
}
|
||||
|
||||
public function linkUser(): void
|
||||
public function linkUser(string $queue = 'ssh'): void
|
||||
{
|
||||
dispatch(new LinkUser($this))->onConnection('ssh');
|
||||
dispatch(new LinkUser($this))->onConnection($queue);
|
||||
}
|
||||
|
||||
public function unlinkUser(): void
|
||||
public function unlinkUser(string $queue = 'ssh'): void
|
||||
{
|
||||
dispatch(new UnlinkUser($this))->onConnection('ssh');
|
||||
dispatch(new UnlinkUser($this))->onConnection($queue);
|
||||
}
|
||||
|
||||
public function getFullUserAttribute(): string
|
||||
|
@ -6,6 +6,7 @@
|
||||
use App\Enums\DeploymentStatus;
|
||||
use App\Enums\SiteStatus;
|
||||
use App\Enums\SslStatus;
|
||||
use App\Events\Broadcast;
|
||||
use App\Exceptions\SourceControlIsNotConnected;
|
||||
use App\Jobs\Site\ChangePHPVersion;
|
||||
use App\Jobs\Site\Deploy;
|
||||
@ -18,6 +19,7 @@
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
|
||||
@ -392,4 +394,49 @@ public function getSshKeyNameAttribute(): string
|
||||
{
|
||||
return str('site_'.$this->id)->toString();
|
||||
}
|
||||
|
||||
public function installationFinished(): void
|
||||
{
|
||||
$this->update([
|
||||
'status' => SiteStatus::READY,
|
||||
'progress' => 100,
|
||||
]);
|
||||
event(
|
||||
new Broadcast('install-site-finished', [
|
||||
'site' => $this,
|
||||
])
|
||||
);
|
||||
/** @todo notify */
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function installationFailed(Throwable $e): void
|
||||
{
|
||||
$this->update([
|
||||
'status' => SiteStatus::INSTALLATION_FAILED,
|
||||
]);
|
||||
event(
|
||||
new Broadcast('install-site-failed', [
|
||||
'site' => $this,
|
||||
])
|
||||
);
|
||||
/** @todo notify */
|
||||
Log::error('install-site-error', [
|
||||
'error' => (string) $e,
|
||||
]);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
public function hasFeature(string $feature): bool
|
||||
{
|
||||
return in_array($feature, $this->type()->supportedFeatures());
|
||||
}
|
||||
|
||||
public function isReady(): bool
|
||||
{
|
||||
return $this->status === SiteStatus::READY;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user