Page MenuHomePhabricator

D17463.diff
No OneTemporary

D17463.diff

diff --git a/src/phage/__tests__/PhageAgentTestCase.php b/src/phage/__tests__/PhageAgentTestCase.php
--- a/src/phage/__tests__/PhageAgentTestCase.php
+++ b/src/phage/__tests__/PhageAgentTestCase.php
@@ -20,6 +20,7 @@
'type' => 'EXEC',
'key' => 1,
'command' => 'echo phage',
+ 'timeout' => null,
));
$this->agentExpect(
@@ -30,6 +31,7 @@
'err' => 0,
'stdout' => "phage\n",
'stderr' => '',
+ 'timeout' => false,
),
pht("'%s' for %s", 'echo phage', $name));
diff --git a/src/phage/action/PhageAgentAction.php b/src/phage/action/PhageAgentAction.php
--- a/src/phage/action/PhageAgentAction.php
+++ b/src/phage/action/PhageAgentAction.php
@@ -139,6 +139,7 @@
'type' => 'EXEC',
'key' => $key,
'command' => $command->getCommand()->getUnmaskedString(),
+ 'timeout' => $command->getTimeout(),
));
if ($throttle) {
@@ -183,6 +184,7 @@
$exit_code = $message['err'];
$command->setExitCode($exit_code);
+ $command->setDidTimeout((bool)idx($message, 'timeout'));
if ($exit_code != 0) {
$exit_code = $this->formatOutput(
diff --git a/src/phage/action/PhageExecuteAction.php b/src/phage/action/PhageExecuteAction.php
--- a/src/phage/action/PhageExecuteAction.php
+++ b/src/phage/action/PhageExecuteAction.php
@@ -5,7 +5,10 @@
private $command;
private $label;
+ private $timeout;
+
private $exitCode;
+ private $didTimeout;
public function isContainerAction() {
return false;
@@ -29,6 +32,15 @@
return $this->label;
}
+ public function setTimeout($timeout) {
+ $this->timeout = $timeout;
+ return $this;
+ }
+
+ public function getTimeout() {
+ return $this->timeout;
+ }
+
public function setExitCode($exit_code) {
$this->exitCode = $exit_code;
return $this;
@@ -38,4 +50,13 @@
return $this->exitCode;
}
+ public function setDidTimeout($did_timeout) {
+ $this->didTimeout = $did_timeout;
+ return $this;
+ }
+
+ public function getDidTimeout() {
+ return $this->didTimeout;
+ }
+
}
diff --git a/src/phage/agent/PhagePHPAgent.php b/src/phage/agent/PhagePHPAgent.php
--- a/src/phage/agent/PhagePHPAgent.php
+++ b/src/phage/agent/PhagePHPAgent.php
@@ -71,6 +71,12 @@
$cmd = $spec['command'];
$future = new ExecFuture('%C', $cmd);
+
+ $timeout = $spec['timeout'];
+ if ($timeout) {
+ $future->setTimeout(ceil($timeout));
+ }
+
$future->isReady();
$this->exec[$key] = $future;
@@ -119,6 +125,7 @@
'err' => $result[0],
'stdout' => $result[1],
'stderr' => $result[2],
+ 'timeout' => (bool)$future->getWasKilledByTimeout(),
));
unset($this->exec[$key]);

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 4, 2:32 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7709154
Default Alt Text
D17463.diff (2 KB)

Event Timeline