Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/step/CommandBuildStepImplementation.php
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | public function execute( | ||||
// Read the next amount of available output every second. | // Read the next amount of available output every second. | ||||
while (!$future->isReady()) { | while (!$future->isReady()) { | ||||
list($stdout, $stderr) = $future->read(); | list($stdout, $stderr) = $future->read(); | ||||
$log_stdout->append($stdout); | $log_stdout->append($stdout); | ||||
$log_stderr->append($stderr); | $log_stderr->append($stderr); | ||||
$future->discardBuffers(); | $future->discardBuffers(); | ||||
// Check to see if we have moved from a "Building" status. This | |||||
// can occur if the user cancels the build, in which case we want | |||||
// to terminate whatever we're doing and return as quickly as possible. | |||||
if ($build->checkForCancellation()) { | |||||
$log_stdout->finalize($start_stdout); | |||||
$log_stderr->finalize($start_stderr); | |||||
$future->resolveKill(); | |||||
return; | |||||
} | |||||
// Wait one second before querying for more data. | // Wait one second before querying for more data. | ||||
sleep(1); | sleep(1); | ||||
} | } | ||||
// Get the return value so we can log that as well. | // Get the return value so we can log that as well. | ||||
list($err) = $future->resolve(); | list($err) = $future->resolve(); | ||||
// Retrieve the last few bits of information. | // Retrieve the last few bits of information. | ||||
list($stdout, $stderr) = $future->read(); | list($stdout, $stderr) = $future->read(); | ||||
$log_stdout->append($stdout); | $log_stdout->append($stdout); | ||||
$log_stderr->append($stderr); | $log_stderr->append($stderr); | ||||
$future->discardBuffers(); | $future->discardBuffers(); | ||||
$log_stdout->finalize($start_stdout); | $log_stdout->finalize($start_stdout); | ||||
$log_stderr->finalize($start_stderr); | $log_stderr->finalize($start_stderr); | ||||
if ($err) { | if ($err) { | ||||
$build->setBuildStatus(HarbormasterBuild::STATUS_FAILED); | throw new Exception(pht('Command failed with error %d.', $err)); | ||||
hach-que: I presume the reason for not using `resolvex` is that we want to dump stdout / stderr to the… | |||||
Not Done Inline ActionsYeah. This would maybe be a little bit nicer as resolvex + capture exception + log + rethrow, I just wanted to get rid of $build mutations in workers. epriestley: Yeah. This would maybe be a little bit nicer as resolvex + capture exception + log + rethrow, I… | |||||
} | } | ||||
} | } | ||||
public function validateSettings() { | public function validateSettings() { | ||||
$settings = $this->getSettings(); | $settings = $this->getSettings(); | ||||
if ($settings['command'] === null || !is_string($settings['command'])) { | if ($settings['command'] === null || !is_string($settings['command'])) { | ||||
return false; | return false; | ||||
Show All 27 Lines |
I presume the reason for not using resolvex is that we want to dump stdout / stderr to the log first?