Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistBuildAgentWorkflow.php
- This file was added.
<?php | |||||
/** | |||||
* Runs a harbormaster build agent on the local machine | |||||
* @group workflow | |||||
*/ | |||||
final class ArcanistBuildAgentWorkflow extends ArcanistBaseWorkflow { | |||||
public function getWorkflowName() { | |||||
return 'agent'; | |||||
} | |||||
public function requiresConduit() { | |||||
return true; | |||||
} | |||||
public function requiresAuthentication() { | |||||
return true; | |||||
} | |||||
public function getCommandSynopses() { | |||||
return phutil_console_format(<<<EOTEXT | |||||
**agent** [__options__] | |||||
EOTEXT | |||||
); | |||||
} | |||||
public function getCommandHelp() { | |||||
return phutil_console_format(<<<EOTEXT | |||||
Supports: http, https | |||||
Runs a Harbormaster agent on the current machine. You must | |||||
explicitly provide the Conduit URI for this command. | |||||
EOTEXT | |||||
); | |||||
} | |||||
public function getArguments() { | |||||
return array( | |||||
'category' => array( | |||||
'short' => 'c', | |||||
'param' => 'category', | |||||
'help' => "Specify the category of the build agent.", | |||||
) | |||||
); | |||||
} | |||||
public function run() { | |||||
$console = PhutilConsole::getConsole(); | |||||
$console->writeOut("Starting build agent...\n"); | |||||
// Pool for agent instructions. | |||||
$conduit = $this->getConduit(); | |||||
while (true) { | |||||
$item = $conduit->callMethodSynchronous('agent.nextbuild', array()); | |||||
if ($item["exists"]) { | |||||
$steps = $item["steps"]; | |||||
// $steps is an array like so: | |||||
// array( | |||||
// array( | |||||
// "class" => "SleepBuildStepImplementation", | |||||
// "details" => "{\"seconds\":5}"), | |||||
// array( | |||||
// "class" => "SleepBuildStepImplementation", | |||||
// "details" => "{\"seconds\":15}")) | |||||
// TODO: Do something with this. | |||||
} else { | |||||
$console->writeOut("> No build to pick up. \n"); | |||||
sleep(15); | |||||
} | |||||
} | |||||
} | |||||
} | |||||