mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 06:56:15 +00:00
Add workers to servers (#547)
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
use App\SSH\Services\PHP\PHP;
|
||||
use App\SSH\Services\Webserver\Webserver;
|
||||
use App\Traits\HasProjectThroughServer;
|
||||
use Database\Factories\SiteFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
@ -44,7 +45,7 @@
|
||||
* @property Collection<int, Command> $commands
|
||||
* @property ?GitHook $gitHook
|
||||
* @property ?DeploymentScript $deploymentScript
|
||||
* @property Collection<int, Queue> $queues
|
||||
* @property Collection<int, Worker> $workers
|
||||
* @property Collection<int, Ssl> $ssls
|
||||
* @property ?Ssl $activeSsl
|
||||
* @property string $ssh_key_name
|
||||
@ -54,7 +55,7 @@
|
||||
*/
|
||||
class Site extends AbstractModel
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\SiteFactory> */
|
||||
/** @use HasFactory<SiteFactory> */
|
||||
use HasFactory;
|
||||
|
||||
use HasProjectThroughServer;
|
||||
@ -105,9 +106,9 @@ public static function boot(): void
|
||||
parent::boot();
|
||||
|
||||
static::deleting(function (Site $site): void {
|
||||
$site->queues()->each(function ($queue): void {
|
||||
/** @var Queue $queue */
|
||||
$queue->delete();
|
||||
$site->workers()->each(function ($worker): void {
|
||||
/** @var Worker $worker */
|
||||
$worker->delete();
|
||||
});
|
||||
$site->ssls()->delete();
|
||||
$site->deployments()->delete();
|
||||
@ -186,11 +187,11 @@ public function deploymentScript(): HasOne
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<Queue, covariant $this>
|
||||
* @return HasMany<Worker, covariant $this>
|
||||
*/
|
||||
public function queues(): HasMany
|
||||
public function workers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Queue::class);
|
||||
return $this->hasMany(Worker::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -401,4 +402,21 @@ public function loadBalancerServers(): HasMany
|
||||
{
|
||||
return $this->hasMany(LoadBalancerServer::class, 'load_balancer_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
public function getSshUsers(): array
|
||||
{
|
||||
$users = [
|
||||
'root',
|
||||
$this->server->getSshUser(),
|
||||
];
|
||||
|
||||
if ($this->isIsolated()) {
|
||||
$users[] = $this->user;
|
||||
}
|
||||
|
||||
return $users;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user