diff --git a/src/Deployment/FtpServer.php b/src/Deployment/FtpServer.php index 2992b10..d5745bc 100644 --- a/src/Deployment/FtpServer.php +++ b/src/Deployment/FtpServer.php @@ -64,6 +64,9 @@ public function __construct(string $url, bool $passiveMode = true) */ public function connect(): void { + if ($this->connection) { // reconnect? + @ftp_close($this->connection); // @ may fail + } $this->connection = $this->url['scheme'] === 'ftp' ? Safe::ftp_connect($this->url['host'], $this->url['port'] ?? 21) : Safe::ftp_ssl_connect($this->url['host'], $this->url['port'] ?? 21); diff --git a/src/Deployment/RetryServer.php b/src/Deployment/RetryServer.php index cde488c..2e67387 100644 --- a/src/Deployment/RetryServer.php +++ b/src/Deployment/RetryServer.php @@ -115,7 +115,7 @@ private function retry(string $method, array $args) if ($counter < self::RETRIES) { if ($e->getMessage() !== $lastError) { $lastError = $e->getMessage(); - $this->logger->log("Error: $lastError", 'red'); + $this->logger->log("Error: $e", 'red'); } if ($method !== 'connect') { diff --git a/src/Deployment/SshServer.php b/src/Deployment/SshServer.php index cd37e43..e7cac81 100644 --- a/src/Deployment/SshServer.php +++ b/src/Deployment/SshServer.php @@ -72,6 +72,9 @@ public function __construct( */ public function connect(): void { + if ($this->connection) { // reconnect? + @ssh2_disconnect($this->connection); // @ may fail + } $this->connection = Safe::ssh2_connect($this->url['host'], $this->url['port'] ?? 22); if (isset($this->url['pass'])) { Safe::ssh2_auth_password($this->connection, urldecode($this->url['user']), urldecode($this->url['pass']));