Skip to content

Commit

Permalink
Merge pull request #82 from tal7aouy/tal7aouy
Browse files Browse the repository at this point in the history
set timeout
  • Loading branch information
freekmurze authored May 15, 2023
2 parents 05ac5a2 + 740d804 commit 7889f8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ Alternatively you can use the `usePort` function:
```php
Ssh::create('user', 'host')->usePort($port);
```
### Setting a timeout

You can set a timeout for the command.


```php
Ssh::create('user', 'host')->setTimeout(100);
```

### Specifying a jump host

Expand Down
12 changes: 11 additions & 1 deletion src/Ssh.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ public function enableStrictHostKeyChecking(): self

return $this;
}

public function setTimeout(int $timeout): self
{
$this->extraOptions['timeout'] = $timeout;

return $this;
}

public function disableStrictHostKeyChecking(): self
{
Expand Down Expand Up @@ -246,7 +253,7 @@ protected function run(string $command, string $method = 'run'): Process
{
$process = Process::fromShellCommandline($command);

$process->setTimeout(0);
$process->setTimeout($this->extraOptions['timeout'] ?? 0);

($this->processConfigurationClosure)($process);

Expand All @@ -266,4 +273,7 @@ protected function getTargetForSsh(): string
{
return "{$this->user}@{$this->host}";
}



}

0 comments on commit 7889f8f

Please sign in to comment.