本文整理汇总了PHP中PhabricatorWorker类的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorWorker类的具体用法?PHP PhabricatorWorker怎么用?PHP PhabricatorWorker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PhabricatorWorker类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(PhutilArgumentParser $args)
{
$ids = $args->getArg('id');
if (!$ids) {
throw new PhutilArgumentUsageException(pht('Specify one or more lease IDs to release with "%s".', '--id'));
}
$viewer = $this->getViewer();
$drydock_phid = id(new PhabricatorDrydockApplication())->getPHID();
$leases = id(new DrydockLeaseQuery())->setViewer($viewer)->withIDs($ids)->execute();
PhabricatorWorker::setRunAllTasksInProcess(true);
foreach ($ids as $id) {
$lease = idx($leases, $id);
if (!$lease) {
echo tsprintf("%s\n", pht('Lease "%s" does not exist.', $id));
continue;
}
if (!$lease->canRelease()) {
echo tsprintf("%s\n", pht('Lease "%s" is not releasable.', $id));
continue;
}
$command = DrydockCommand::initializeNewCommand($viewer)->setTargetPHID($lease->getPHID())->setAuthorPHID($drydock_phid)->setCommand(DrydockCommand::COMMAND_RELEASE)->save();
$lease->scheduleUpdate();
echo tsprintf("%s\n", pht('Scheduled release of lease "%s".', $id));
}
}
开发者ID:pugong,项目名称:phabricator,代码行数:25,代码来源:DrydockManagementReleaseLeaseWorkflow.php
示例2: executeBuildCommand
private function executeBuildCommand(HarbormasterBuild $build, HarbormasterBuildTransaction $xaction)
{
$command = $xaction->getNewValue();
switch ($command) {
case HarbormasterBuildCommand::COMMAND_RESTART:
$issuable = $build->canRestartBuild();
break;
case HarbormasterBuildCommand::COMMAND_PAUSE:
$issuable = $build->canPauseBuild();
break;
case HarbormasterBuildCommand::COMMAND_RESUME:
$issuable = $build->canResumeBuild();
break;
case HarbormasterBuildCommand::COMMAND_ABORT:
$issuable = $build->canAbortBuild();
break;
default:
throw new Exception(pht('Unknown command %s', $command));
}
if (!$issuable) {
return;
}
$actor = $this->getActor();
if (!$build->canIssueCommand($actor, $command)) {
return;
}
id(new HarbormasterBuildCommand())->setAuthorPHID($xaction->getAuthorPHID())->setTargetPHID($build->getPHID())->setCommand($command)->save();
PhabricatorWorker::scheduleTask('HarbormasterBuildWorker', array('buildID' => $build->getID()), array('objectPHID' => $build->getPHID()));
}
开发者ID:rchicoli,项目名称:phabricator,代码行数:29,代码来源:HarbormasterBuildTransactionEditor.php
示例3: execute
public function execute(PhutilArgumentParser $args)
{
$viewer = $this->getViewer();
$names = $args->getArg('buildable');
if (count($names) != 1) {
throw new PhutilArgumentUsageException(pht('Specify exactly one buildable object, by object name.'));
}
$name = head($names);
$buildable = id(new PhabricatorObjectQuery())->setViewer($viewer)->withNames($names)->executeOne();
if (!$buildable) {
throw new PhutilArgumentUsageException(pht('No such buildable "%s"!', $name));
}
if (!$buildable instanceof HarbormasterBuildableInterface) {
throw new PhutilArgumentUsageException(pht('Object "%s" is not a buildable!', $name));
}
$plan_id = $args->getArg('plan');
if (!$plan_id) {
throw new PhutilArgumentUsageException(pht('Use --plan to specify a build plan to run.'));
}
$plan = id(new HarbormasterBuildPlanQuery())->setViewer($viewer)->withIDs(array($plan_id))->executeOne();
if (!$plan) {
throw new PhutilArgumentUsageException(pht('Build plan "%s" does not exist.', $plan_id));
}
$console = PhutilConsole::getConsole();
$buildable = HarbormasterBuildable::initializeNewBuildable($viewer)->setIsManualBuildable(true)->setBuildablePHID($buildable->getHarbormasterBuildablePHID())->setContainerPHID($buildable->getHarbormasterContainerPHID())->save();
$console->writeOut("%s\n", pht('Applying plan %s to new buildable %s...', $plan->getID(), 'B' . $buildable->getID()));
$console->writeOut("\n %s\n\n", PhabricatorEnv::getProductionURI('/B' . $buildable->getID()));
PhabricatorWorker::setRunAllTasksInProcess(true);
$buildable->applyPlan($plan);
$console->writeOut("%s\n", pht('Done.'));
return 0;
}
开发者ID:denghp,项目名称:phabricator,代码行数:32,代码来源:HarbormasterManagementBuildWorkflow.php
示例4: doWork
protected function doWork()
{
$lock = $this->acquireJobLock();
$job = $this->loadJob();
$actor = $this->loadActor($job);
$status = $job->getStatus();
switch ($status) {
case PhabricatorWorkerBulkJob::STATUS_WAITING:
// This is what we expect. Other statuses indicate some kind of race
// is afoot.
break;
default:
throw new PhabricatorWorkerPermanentFailureException(pht('Found unexpected job status ("%s").', $status));
}
$tasks = $job->createTasks();
foreach ($tasks as $task) {
$task->save();
}
$this->updateJobStatus($job, PhabricatorWorkerBulkJob::STATUS_RUNNING);
$lock->unlock();
foreach ($tasks as $task) {
PhabricatorWorker::scheduleTask('PhabricatorWorkerBulkJobTaskWorker', array('jobID' => $job->getID(), 'taskID' => $task->getID()), array('priority' => PhabricatorWorker::PRIORITY_BULK));
}
$this->updateJob($job);
}
开发者ID:pugong,项目名称:phabricator,代码行数:25,代码来源:PhabricatorWorkerBulkJobCreateWorker.php
示例5: execute
protected function execute(ConduitAPIRequest $request)
{
$viewer = $request->getUser();
$build_target_phid = $request->getValue('buildTargetPHID');
$message_type = $request->getValue('type');
$build_target = id(new HarbormasterBuildTargetQuery())->setViewer($viewer)->withPHIDs(array($build_target_phid))->executeOne();
if (!$build_target) {
throw new Exception(pht('No such build target!'));
}
$save = array();
$lint_messages = $request->getValue('lint', array());
foreach ($lint_messages as $lint) {
$save[] = HarbormasterBuildLintMessage::newFromDictionary($build_target, $lint);
}
$unit_messages = $request->getValue('unit', array());
foreach ($unit_messages as $unit) {
$save[] = HarbormasterBuildUnitMessage::newFromDictionary($build_target, $unit);
}
$save[] = HarbormasterBuildMessage::initializeNewMessage($viewer)->setBuildTargetPHID($build_target->getPHID())->setType($message_type);
$build_target->openTransaction();
foreach ($save as $object) {
$object->save();
}
$build_target->saveTransaction();
// If the build has completely paused because all steps are blocked on
// waiting targets, this will resume it.
PhabricatorWorker::scheduleTask('HarbormasterBuildWorker', array('buildID' => $build_target->getBuild()->getID()));
return null;
}
开发者ID:hrb518,项目名称:phabricator,代码行数:29,代码来源:HarbormasterSendMessageConduitAPIMethod.php
示例6: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$viewer = $this->getViewer();
$subscription_phid = $args->getArg('subscription');
if (!$subscription_phid) {
throw new PhutilArgumentUsageException(pht('Specify which subscription to invoice with %s.', '--subscription'));
}
$subscription = id(new PhortuneSubscriptionQuery())->setViewer($viewer)->withPHIDs(array($subscription_phid))->needTriggers(true)->executeOne();
if (!$subscription) {
throw new PhutilArgumentUsageException(pht('Unable to load subscription with PHID "%s".', $subscription_phid));
}
$now = $args->getArg('now');
$now = $this->parseTimeArgument($now);
if (!$now) {
$now = PhabricatorTime::getNow();
}
$time_guard = PhabricatorTime::pushTime($now, date_default_timezone_get());
$console->writeOut("%s\n", pht('Set current time to %s.', phabricator_datetime(PhabricatorTime::getNow(), $viewer)));
$auto_range = $args->getArg('auto-range');
$last_arg = $args->getArg('last');
$next_arg = $args->getARg('next');
if (!$auto_range && !$last_arg && !$next_arg) {
throw new PhutilArgumentUsageException(pht('Specify a billing range with %s and %s, or use %s.', '--last', '--next', '--auto-range'));
} else {
if (!$auto_range & (!$last_arg || !$next_arg)) {
throw new PhutilArgumentUsageException(pht('When specifying %s or %s, you must specify both arguments ' . 'to define the beginning and end of the billing range.', '--last', '--next'));
} else {
if (!$auto_range && ($last_arg && $next_arg)) {
$last_time = $this->parseTimeArgument($args->getArg('last'));
$next_time = $this->parseTimeArgument($args->getArg('next'));
} else {
if ($auto_range && ($last_arg || $next_arg)) {
throw new PhutilArgumentUsageException(pht('Use either %s or %s and %s to specify the ' . 'billing range, but not both.', '--auto-range', '--last', '--next'));
} else {
$trigger = $subscription->getTrigger();
$event = $trigger->getEvent();
if (!$event) {
throw new PhutilArgumentUsageException(pht('Unable to calculate %s, this subscription has not been ' . 'scheduled for billing yet. Wait for the trigger daemon to ' . 'schedule the subscription.', '--auto-range'));
}
$last_time = $event->getLastEventEpoch();
$next_time = $event->getNextEventEpoch();
}
}
}
}
$console->writeOut("%s\n", pht('Preparing to invoice subscription "%s" from %s to %s.', $subscription->getSubscriptionName(), $last_time ? phabricator_datetime($last_time, $viewer) : pht('subscription creation'), phabricator_datetime($next_time, $viewer)));
PhabricatorWorker::setRunAllTasksInProcess(true);
if (!$args->getArg('force')) {
$console->writeOut("**<bg:yellow> %s </bg>**\n%s\n", pht('WARNING'), phutil_console_wrap(pht('Manually invoicing will double bill payment accounts if the ' . 'range overlaps an existing or future invoice. This script is ' . 'intended for testing and development, and should not be part ' . 'of routine billing operations. If you continue, you may ' . 'incorrectly overcharge customers.')));
if (!phutil_console_confirm(pht('Really invoice this subscription?'))) {
throw new Exception(pht('Declining to invoice.'));
}
}
PhabricatorWorker::scheduleTask('PhortuneSubscriptionWorker', array('subscriptionPHID' => $subscription->getPHID(), 'trigger.last-epoch' => $last_time, 'trigger.this-epoch' => $next_time, 'manual' => true), array('objectPHID' => $subscription->getPHID()));
return 0;
}
开发者ID:truSense,项目名称:phabricator,代码行数:57,代码来源:PhabricatorPhortuneManagementInvoiceWorkflow.php
示例7: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$viewer = $this->getViewer();
$tos = $args->getArg('to');
$body = $args->getArg('body');
PhabricatorWorker::setRunAllTasksInProcess(true);
PhabricatorSMSImplementationAdapter::sendSMS($tos, $body);
$console->writeErr("%s\n\n phabricator/ \$ ./bin/sms list-outbound \n\n", pht('Send completed! You can view the list of SMS messages sent by ' . 'running this command:'));
}
开发者ID:pugong,项目名称:phabricator,代码行数:10,代码来源:PhabricatorSMSManagementSendTestWorkflow.php
示例8: releaseLease
private function releaseLease(DrydockLease $lease)
{
$lease->openTransaction();
$lease->setStatus(DrydockLeaseStatus::STATUS_RELEASED)->save();
// TODO: Hold slot locks until destruction?
DrydockSlotLock::releaseLocks($lease->getPHID());
$lease->saveTransaction();
PhabricatorWorker::scheduleTask('DrydockLeaseDestroyWorker', array('leasePHID' => $lease->getPHID()), array('objectPHID' => $lease->getPHID()));
$resource = $lease->getResource();
$blueprint = $resource->getBlueprint();
$blueprint->didReleaseLease($resource, $lease);
}
开发者ID:Robert-Xie,项目名称:phabricator,代码行数:12,代码来源:DrydockLeaseUpdateWorker.php
示例9: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$console->writeOut("%s\n", pht('Adding many test tasks to worker queue. Use ^C to exit.'));
$n = 0;
while (true) {
PhabricatorWorker::scheduleTask('PhabricatorTestWorker', array());
if ($n++ % 100 === 0) {
$console->writeOut('.');
}
}
}
开发者ID:pugong,项目名称:phabricator,代码行数:12,代码来源:PhabricatorWorkerManagementFloodWorkflow.php
示例10: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$is_all = $args->getArg('all');
$is_type = $args->getArg('type');
$is_force = $args->getArg('force');
$obj_names = $args->getArg('objects');
if ($obj_names && ($is_all || $is_type)) {
throw new PhutilArgumentUsageException(pht("You can not name objects to index alongside the '%s' or '%s' flags.", '--all', '--type'));
} else {
if (!$obj_names && !($is_all || $is_type)) {
throw new PhutilArgumentUsageException(pht("Provide one of '%s', '%s' or a list of object names.", '--all', '--type'));
}
}
if ($obj_names) {
$phids = $this->loadPHIDsByNames($obj_names);
} else {
$phids = $this->loadPHIDsByTypes($is_type);
}
if (!$phids) {
throw new PhutilArgumentUsageException(pht('Nothing to index!'));
}
if ($args->getArg('background')) {
$is_background = true;
} else {
PhabricatorWorker::setRunAllTasksInProcess(true);
$is_background = false;
}
if (!$is_background) {
$console->writeOut("%s\n", pht('Run this workflow with "%s" to queue tasks for the daemon workers.', '--background'));
}
$groups = phid_group_by_type($phids);
foreach ($groups as $group_type => $group) {
$console->writeOut("%s\n", pht('Indexing %d object(s) of type %s.', count($group), $group_type));
}
$bar = id(new PhutilConsoleProgressBar())->setTotal(count($phids));
$parameters = array('force' => $is_force);
$any_success = false;
foreach ($phids as $phid) {
try {
PhabricatorSearchWorker::queueDocumentForIndexing($phid, $parameters);
$any_success = true;
} catch (Exception $ex) {
phlog($ex);
}
$bar->update(1);
}
$bar->done();
if (!$any_success) {
throw new Exception(pht('Failed to rebuild search index for any documents.'));
}
}
开发者ID:truSense,项目名称:phabricator,代码行数:52,代码来源:PhabricatorSearchManagementIndexWorkflow.php
示例11: execute
protected function execute(ConduitAPIRequest $request)
{
$viewer = $request->getUser();
$build_target_phid = $request->getValue('buildTargetPHID');
$message_type = $request->getValue('type');
$build_target = id(new HarbormasterBuildTargetQuery())->setViewer($viewer)->withPHIDs(array($build_target_phid))->executeOne();
if (!$build_target) {
throw new Exception(pht('No such build target!'));
}
$message = HarbormasterBuildMessage::initializeNewMessage($viewer)->setBuildTargetPHID($build_target->getPHID())->setType($message_type)->save();
// If the build has completely paused because all steps are blocked on
// waiting targets, this will resume it.
PhabricatorWorker::scheduleTask('HarbormasterBuildWorker', array('buildID' => $build_target->getBuild()->getID()));
return null;
}
开发者ID:denghp,项目名称:phabricator,代码行数:15,代码来源:HarbormasterSendMessageConduitAPIMethod.php
示例12: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$viewer = $this->getViewer();
$triggers = $this->loadTriggers($args);
$now = $args->getArg('now');
$now = $this->parseTimeArgument($now);
if (!$now) {
$now = PhabricatorTime::getNow();
}
$time_guard = PhabricatorTime::pushTime($now, date_default_timezone_get());
$console->writeOut("%s\n", pht('Set current time to %s.', phabricator_datetime(PhabricatorTime::getNow(), $viewer)));
$last_time = $this->parseTimeArgument($args->getArg('last'));
$next_time = $this->parseTimeArgument($args->getArg('next'));
PhabricatorWorker::setRunAllTasksInProcess(true);
foreach ($triggers as $trigger) {
$console->writeOut("%s\n", pht('Executing trigger %s.', $this->describeTrigger($trigger)));
$event = $trigger->getEvent();
if ($event) {
if (!$last_time) {
$last_time = $event->getLastEventEpoch();
}
if (!$next_time) {
$next_time = $event->getNextEventEpoch();
}
}
if (!$next_time) {
$console->writeOut("%s\n", pht('Trigger is not scheduled to execute. Use --next to simluate ' . 'a scheduled event.'));
continue;
} else {
$console->writeOut("%s\n", pht('Executing event as though it was scheduled to execute at %s.', phabricator_datetime($next_time, $viewer)));
}
if (!$last_time) {
$console->writeOut("%s\n", pht('Executing event as though it never previously executed.'));
} else {
$console->writeOut("%s\n", pht('Executing event as though it previously executed at %s.', phabricator_datetime($last_time, $viewer)));
}
$trigger->executeTrigger($last_time, $next_time);
$reschedule_time = $trigger->getNextEventEpoch($next_time, $is_reschedule = true);
if (!$reschedule_time) {
$console->writeOut("%s\n", pht('After executing under these conditions, this event would never ' . 'execute again.'));
} else {
$console->writeOut("%s\n", pht('After executing under these conditions, this event would ' . 'next execute at %s.', phabricator_datetime($reschedule_time, $viewer)));
}
}
return 0;
}
开发者ID:pugong,项目名称:phabricator,代码行数:47,代码来源:PhabricatorWorkerTriggerManagementFireWorkflow.php
示例13: execute
public function execute(PhutilArgumentParser $args)
{
$viewer = $this->getViewer();
$ids = $args->getArg('id');
if (!$ids) {
throw new PhutilArgumentUsageException(pht('Specify one or more lease IDs to update with "%s".', '--id'));
}
$leases = id(new DrydockLeaseQuery())->setViewer($viewer)->withIDs($ids)->execute();
PhabricatorWorker::setRunAllTasksInProcess(true);
foreach ($ids as $id) {
$lease = idx($leases, $id);
if (!$lease) {
echo tsprintf("%s\n", pht('Lease "%s" does not exist.', $id));
continue;
}
echo tsprintf("%s\n", pht('Updating lease "%s".', $id));
$lease->scheduleUpdate();
}
}
开发者ID:pugong,项目名称:phabricator,代码行数:19,代码来源:DrydockManagementUpdateLeaseWorkflow.php
示例14: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$is_all = $args->getArg('all');
$is_type = $args->getArg('type');
$obj_names = $args->getArg('objects');
if ($obj_names && ($is_all || $is_type)) {
throw new PhutilArgumentUsageException("You can not name objects to index alongside the '--all' or '--type' " . "flags.");
} else {
if (!$obj_names && !($is_all || $is_type)) {
throw new PhutilArgumentUsageException("Provide one of '--all', '--type' or a list of object names.");
}
}
if ($obj_names) {
$phids = $this->loadPHIDsByNames($obj_names);
} else {
$phids = $this->loadPHIDsByTypes($is_type);
}
if (!$phids) {
throw new PhutilArgumentUsageException('Nothing to index!');
}
if ($args->getArg('background')) {
$is_background = true;
} else {
PhabricatorWorker::setRunAllTasksInProcess(true);
$is_background = false;
}
if (!$is_background) {
$console->writeOut("%s\n", pht('Run this workflow with "--background" to queue tasks for the ' . 'daemon workers.'));
}
$groups = phid_group_by_type($phids);
foreach ($groups as $group_type => $group) {
$console->writeOut("%s\n", pht('Indexing %d object(s) of type %s.', count($group), $group_type));
}
$bar = id(new PhutilConsoleProgressBar())->setTotal(count($phids));
$indexer = new PhabricatorSearchIndexer();
foreach ($phids as $phid) {
$indexer->queueDocumentForIndexing($phid);
$bar->update(1);
}
$bar->done();
}
开发者ID:denghp,项目名称:phabricator,代码行数:42,代码来源:PhabricatorSearchManagementIndexWorkflow.php
示例15: execute
public function execute(PhutilArgumentParser $args)
{
$viewer = $this->getViewer();
$force_update = $args->getArg('force');
$names = $args->getArg('buildable');
if (count($names) != 1) {
throw new PhutilArgumentUsageException(pht('Specify exactly one buildable, by object name.'));
}
$buildable = id(new PhabricatorObjectQuery())->setViewer($viewer)->withNames($names)->executeOne();
if (!$buildable) {
throw new PhutilArgumentUsageException(pht('No such buildable "%s"!', head($names)));
}
if (!$buildable instanceof HarbormasterBuildable) {
throw new PhutilArgumentUsageException(pht('Object "%s" is not a Harbormaster Buildable!', head($names)));
}
// Reload the buildable directly to get builds.
$buildable = id(new HarbormasterBuildableQuery())->setViewer($viewer)->withIDs(array($buildable->getID()))->needBuilds(true)->executeOne();
$builds = $buildable->getBuilds();
$builds = mpull($builds, null, 'getID');
$build_id = $args->getArg('build');
if ($build_id) {
$builds = array_select_keys($builds, array($build_id));
if (!$builds) {
throw new PhutilArgumentUsageException(pht('The specified buildable does not have a build with ID "%s".', $build_id));
}
}
$console = PhutilConsole::getConsole();
if (!$args->getArg('background')) {
PhabricatorWorker::setRunAllTasksInProcess(true);
}
foreach ($builds as $build) {
$console->writeOut("%s\n", pht('Updating build %d of buildable %s...', $build->getID(), $buildable->getMonogram()));
$engine = id(new HarbormasterBuildEngine())->setViewer($viewer)->setBuild($build);
if ($force_update) {
$engine->setForceBuildableUpdate(true);
}
$engine->continueBuild();
}
$console->writeOut("%s\n", pht('Done.'));
return 0;
}
开发者ID:denghp,项目名称:phabricator,代码行数:41,代码来源:HarbormasterManagementUpdateWorkflow.php
示例16: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$ids = $args->getArg('id');
if (!$ids) {
throw new PhutilArgumentUsageException("Use the '--id' flag to specify one or more messages to resend.");
}
$messages = id(new PhabricatorMetaMTAMail())->loadAllWhere('id IN (%Ld)', $ids);
if ($ids) {
$ids = array_fuse($ids);
$missing = array_diff_key($ids, $messages);
if ($missing) {
throw new PhutilArgumentUsageException('Some specified messages do not exist: ' . implode(', ', array_keys($missing)));
}
}
foreach ($messages as $message) {
$message->setStatus(PhabricatorMetaMTAMail::STATUS_QUEUE);
$message->save();
$mailer_task = PhabricatorWorker::scheduleTask('PhabricatorMetaMTAWorker', $message->getID(), PhabricatorWorker::PRIORITY_ALERTS);
$console->writeOut("Queued message #%d for resend.\n", $message->getID());
}
}
开发者ID:denghp,项目名称:phabricator,代码行数:22,代码来源:PhabricatorMailManagementResendWorkflow.php
示例17: executeBuildCommand
private function executeBuildCommand(HarbormasterBuild $build, HarbormasterBuildTransaction $xaction)
{
$command = $xaction->getNewValue();
switch ($command) {
case HarbormasterBuildCommand::COMMAND_RESTART:
$issuable = $build->canRestartBuild();
break;
case HarbormasterBuildCommand::COMMAND_STOP:
$issuable = $build->canStopBuild();
break;
case HarbormasterBuildCommand::COMMAND_RESUME:
$issuable = $build->canResumeBuild();
break;
default:
throw new Exception("Unknown command {$command}");
}
if (!$issuable) {
return;
}
id(new HarbormasterBuildCommand())->setAuthorPHID($xaction->getAuthorPHID())->setTargetPHID($build->getPHID())->setCommand($command)->save();
PhabricatorWorker::scheduleTask('HarbormasterBuildWorker', array('buildID' => $build->getID()));
}
开发者ID:denghp,项目名称:phabricator,代码行数:22,代码来源:HarbormasterBuildTransactionEditor.php
示例18: releaseResource
private function releaseResource(DrydockResource $resource)
{
if ($resource->getStatus() != DrydockResourceStatus::STATUS_ACTIVE) {
// If we had multiple release commands
// This command is only meaningful to resources in the "Open" state.
return;
}
$viewer = $this->getViewer();
$drydock_phid = id(new PhabricatorDrydockApplication())->getPHID();
$resource->openTransaction();
$resource->setStatus(DrydockResourceStatus::STATUS_RELEASED)->save();
// TODO: Hold slot locks until destruction?
DrydockSlotLock::releaseLocks($resource->getPHID());
$resource->saveTransaction();
$statuses = array(DrydockLeaseStatus::STATUS_PENDING, DrydockLeaseStatus::STATUS_ACQUIRED, DrydockLeaseStatus::STATUS_ACTIVE);
$leases = id(new DrydockLeaseQuery())->setViewer($viewer)->withResourcePHIDs(array($resource->getPHID()))->withStatuses($statuses)->execute();
foreach ($leases as $lease) {
$command = DrydockCommand::initializeNewCommand($viewer)->setTargetPHID($lease->getPHID())->setAuthorPHID($drydock_phid)->setCommand(DrydockCommand::COMMAND_RELEASE)->save();
$lease->scheduleUpdate();
}
PhabricatorWorker::scheduleTask('DrydockResourceDestroyWorker', array('resourcePHID' => $resource->getPHID()), array('objectPHID' => $resource->getPHID()));
}
开发者ID:Robert-Xie,项目名称:phabricator,代码行数:22,代码来源:DrydockResourceUpdateWorker.php
示例19: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$resource_type = $args->getArg('type');
if (!$resource_type) {
throw new PhutilArgumentUsageException(pht('Specify a resource type with `%s`.', '--type'));
}
$attributes = $args->getArg('attributes');
if ($attributes) {
$options = new PhutilSimpleOptions();
$options->setCaseSensitive(true);
$attributes = $options->parse($attributes);
}
PhabricatorWorker::setRunAllTasksInProcess(true);
$lease = id(new DrydockLease())->setResourceType($resource_type);
if ($attributes) {
$lease->setAttributes($attributes);
}
$lease->queueForActivation()->waitUntilActive();
$console->writeOut("%s\n", pht('Acquired Lease %s', $lease->getID()));
return 0;
}
开发者ID:fengshao0907,项目名称:phabricator,代码行数:22,代码来源:DrydockManagementLeaseWorkflow.php
示例20: execute
public function execute(PhutilArgumentParser $args)
{
$viewer = $this->getViewer();
$drydock_phid = id(new PhabricatorDrydockApplication())->getPHID();
PhabricatorWorker::setRunAllTasksInProcess(true);
$resources = id(new DrydockResourceQuery())->setViewer($viewer)->withStatuses(array(DrydockResourceStatus::STATUS_ACTIVE))->execute();
foreach ($resources as $resource) {
$command = DrydockCommand::initializeNewCommand($viewer)->setTargetPHID($resource->getPHID())->setAuthorPHID($drydock_phid)->setCommand(DrydockCommand::COMMAND_RECLAIM)->save();
$resource->scheduleUpdate();
$resource = $resource->reload();
$name = pht('Resource %d: %s', $resource->getID(), $resource->getResourceName());
switch ($resource->getStatus()) {
case DrydockResourceStatus::STATUS_RELEASED:
case DrydockResourceStatus::STATUS_DESTROYED:
echo tsprintf("%s\n", pht('Resource "%s" was reclaimed.', $name));
break;
default:
echo tsprintf("%s\n", pht('Resource "%s" could not be reclaimed.', $name));
break;
}
}
}
开发者ID:mduan,项目名称:phabricator,代码行数:22,代码来源:DrydockManagementReclaimWorkflow.php
注:本文中的PhabricatorWorker类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论