Differential D19250 Diff 46089 src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php
<?php | <?php | ||||
final class DiffusionGitReceivePackSSHWorkflow extends DiffusionGitSSHWorkflow { | final class DiffusionGitReceivePackSSHWorkflow extends DiffusionGitSSHWorkflow { | ||||
protected function didConstruct() { | protected function didConstruct() { | ||||
$this->setName('git-receive-pack'); | $this->setName('git-receive-pack'); | ||||
$this->setArguments( | $this->setArguments( | ||||
array( | array( | ||||
array( | array( | ||||
'name' => 'dir', | 'name' => 'dir', | ||||
'wildcard' => true, | 'wildcard' => true, | ||||
), | ), | ||||
)); | )); | ||||
} | } | ||||
protected function executeRepositoryOperations() { | protected function executeRepositoryOperations() { | ||||
$host_wait_start = microtime(true); | |||||
$repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
$viewer = $this->getSSHUser(); | $viewer = $this->getSSHUser(); | ||||
$device = AlmanacKeys::getLiveDevice(); | $device = AlmanacKeys::getLiveDevice(); | ||||
// This is a write, and must have write access. | // This is a write, and must have write access. | ||||
$this->requireWriteAccess(); | $this->requireWriteAccess(); | ||||
$cluster_engine = id(new DiffusionRepositoryClusterEngine()) | $cluster_engine = id(new DiffusionRepositoryClusterEngine()) | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if ($caught) { | ||||
throw $caught; | throw $caught; | ||||
} | } | ||||
if (!$err) { | if (!$err) { | ||||
$repository->writeStatusMessage( | $repository->writeStatusMessage( | ||||
PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE, | PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE, | ||||
PhabricatorRepositoryStatusMessage::CODE_OKAY); | PhabricatorRepositoryStatusMessage::CODE_OKAY); | ||||
$this->waitForGitClient(); | $this->waitForGitClient(); | ||||
$host_wait_end = microtime(true); | |||||
$this->updatePushLogWithTimingInformation( | |||||
$this->getClusterEngineLogProperty('writeWait'), | |||||
$this->getClusterEngineLogProperty('readWait'), | |||||
($host_wait_end - $host_wait_start)); | |||||
} | } | ||||
return $err; | return $err; | ||||
} | } | ||||
private function executeRepositoryCommand($command) { | private function executeRepositoryCommand($command) { | ||||
$repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
$command = PhabricatorDaemon::sudoCommandAsDaemonUser($command); | $command = PhabricatorDaemon::sudoCommandAsDaemonUser($command); | ||||
$future = id(new ExecFuture('%C', $command)) | $future = id(new ExecFuture('%C', $command)) | ||||
->setEnv($this->getEnvironment()); | ->setEnv($this->getEnvironment()); | ||||
return $this->newPassthruCommand() | return $this->newPassthruCommand() | ||||
->setIOChannel($this->getIOChannel()) | ->setIOChannel($this->getIOChannel()) | ||||
->setCommandChannelFromExecFuture($future) | ->setCommandChannelFromExecFuture($future) | ||||
->execute(); | ->execute(); | ||||
} | } | ||||
private function updatePushLogWithTimingInformation( | |||||
$write_wait, | |||||
$read_wait, | |||||
$host_wait) { | |||||
if ($write_wait !== null) { | |||||
$write_wait = (int)(1000000 * $write_wait); | |||||
} | |||||
if ($read_wait !== null) { | |||||
$read_wait = (int)(1000000 * $read_wait); | |||||
} | |||||
if ($host_wait !== null) { | |||||
$host_wait = (int)(1000000 * $host_wait); | |||||
} | |||||
$identifier = $this->getRequestIdentifier(); | |||||
$event = new PhabricatorRepositoryPushEvent(); | |||||
$conn = $event->establishConnection('w'); | |||||
queryfx( | |||||
$conn, | |||||
'UPDATE %T SET writeWait = %nd, readWait = %nd, hostWait = %nd | |||||
WHERE requestIdentifier = %s', | |||||
$event->getTableName(), | |||||
$write_wait, | |||||
$read_wait, | |||||
$host_wait, | |||||
$identifier); | |||||
} | |||||
} | } |