Mysql 8.4 support and Stream log output (#407)

This commit is contained in:
Saeed Vaziry
2024-12-24 23:30:52 +01:00
committed by GitHub
parent 924920e6e8
commit dfdd50beb7
4 changed files with 47 additions and 5 deletions

View File

@ -93,7 +93,11 @@ public function connect(bool $sftp = false): void
*/
public function exec(string $command, string $log = '', ?int $siteId = null, ?bool $stream = false, ?callable $streamCallback = null): string
{
if (! $this->log && $log) {
if (! $log) {
$log = 'run-command';
}
if (! $this->log) {
$this->log = ServerLog::make($this->server, $log);
if ($siteId) {
$this->log->forSite($siteId);
@ -117,16 +121,18 @@ public function exec(string $command, string $log = '', ?int $siteId = null, ?bo
$this->connection->setTimeout(0);
if ($stream) {
$this->connection->exec($command, function ($output) use ($streamCallback) {
$this->log?->write($output);
$this->log->write($output);
return $streamCallback($output);
});
return '';
} else {
$output = $this->connection->exec($command);
$this->log?->write($output);
$output = '';
$this->connection->exec($command, function ($out) use (&$output) {
$this->log->write($out);
$output .= $out;
});
if ($this->connection->getExitStatus() !== 0 || Str::contains($output, 'VITO_SSH_ERROR')) {
throw new SSHCommandError(