mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
Mysql 8.4 support and Stream log output (#407)
This commit is contained in:
@ -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(
|
||||
|
Reference in New Issue
Block a user