mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-07 17:02:34 +00:00
#591 - server-settings
This commit is contained in:
29
app/Console/Commands/CheckServersConnectionCommand.php
Normal file
29
app/Console/Commands/CheckServersConnectionCommand.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Enums\ServerStatus;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CheckServersConnectionCommand extends Command
|
||||
{
|
||||
protected $signature = 'servers:check';
|
||||
|
||||
protected $description = 'Check servers connection status';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
Server::query()->whereIn('status', [
|
||||
ServerStatus::READY,
|
||||
ServerStatus::DISCONNECTED,
|
||||
])->chunk(50, function ($servers) {
|
||||
/** @var Server $server */
|
||||
foreach ($servers as $server) {
|
||||
dispatch(function () use ($server) {
|
||||
$server->checkConnection();
|
||||
})->onConnection('ssh');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ protected function schedule(Schedule $schedule): void
|
||||
$schedule->command('backups:run "0 0 1 * *"')->monthly();
|
||||
$schedule->command('metrics:delete-older-metrics')->daily();
|
||||
$schedule->command('metrics:get')->everyMinute();
|
||||
$schedule->command('servers:check')->everyFiveMinutes();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user