Skip to content

Commit 085a230

Browse files
authored
[1.x] Adds --timeout option (#45)
* Adds `--timeout` option * Adjusts * stlye
1 parent 8530355 commit 085a230

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/Console/Commands/PailCommand.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class PailCommand extends Command
2525
{--message= : Filter the logs by the given message}
2626
{--level= : Filter the logs by the given level}
2727
{--auth= : Filter the logs by the given authenticated ID}
28-
{--user= : Filter the logs by the given authenticated ID (alias for --auth)}';
28+
{--user= : Filter the logs by the given authenticated ID (alias for --auth)}
29+
{--timeout=3600 : The maximum execution time in seconds}';
2930

3031
/**
3132
* {@inheritDoc}

src/Options.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Options
1111
* Creates a new instance of the tail options.
1212
*/
1313
public function __construct(
14+
protected int $timeout,
1415
protected ?string $authId,
1516
protected ?string $level,
1617
protected ?string $filter,
@@ -36,7 +37,9 @@ public static function fromCommand(Command $command): static
3637
$message = $command->option('message');
3738
assert(is_string($message) || $message === null);
3839

39-
return new static($authId, $level, $filter, $message);
40+
$timeout = (int) $command->option('timeout');
41+
42+
return new static($timeout, $authId, $level, $filter, $message);
4043
}
4144

4245
/**
@@ -62,4 +65,12 @@ public function accepts(MessageLogged $messageLogged): bool
6265

6366
return true;
6467
}
68+
69+
/**
70+
* Returns the number of seconds before the process is killed.
71+
*/
72+
public function timeout(): int
73+
{
74+
return $this->timeout;
75+
}
6576
}

src/ProcessFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function run(File $file, OutputInterface $output, string $basePath, Optio
1919

2020
$remainingBuffer = '';
2121

22-
Process::timeout(3600)
22+
Process::timeout($options->timeout())
2323
->tty(false)
2424
->run(
2525
$this->command($file),

0 commit comments

Comments
 (0)