Skip to content

Commit 1c62a35

Browse files
author
epriestley
committed
Run one daemon to pull all working copies, not one daemon per working copy
Summary: Allow the pull daemon to take a list of repositories. By default, pull all repositories. Make some effort to respect pull frequencies, although we'll necessarily suffer a bit if running with only one process. NOTE: We still launch one discovery daemon per working copy, so this only cuts the daemon count in half. Test Plan: - Ran `phd debug pulllocal`, verified behavior. - Ran `pull.php P MTEST SVNTEST --trace`, verified it pulled the repos and ran the right commands. - Ran `phd repository-launch-master`, verified the right daemons launched, checked daemon console. - Ran `phd repository-launch-readonly`, verified the right daemon launched, checked daemon console. Reviewers: btrahan, csilvers, davidreuss Reviewed By: csilvers CC: aran Differential Revision: https://secure.phabricator.com/D2418
1 parent 8c6fa3e commit 1c62a35

File tree

10 files changed

+359
-282
lines changed

10 files changed

+359
-282
lines changed

scripts/daemon/phabricator_daemon_launcher.php

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?php
33

44
/*
5-
* Copyright 2011 Facebook, Inc.
5+
* Copyright 2012 Facebook, Inc.
66
*
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
@@ -49,35 +49,30 @@ function must_have_extension($ext) {
4949
exit($err);
5050

5151
case 'repository-launch-readonly':
52-
$need_launch = phd_load_tracked_repositories_of_type('git');
52+
$need_launch = phd_load_tracked_repositories();
5353
if (!$need_launch) {
5454
echo "There are no repositories with tracking enabled.\n";
55-
} else {
56-
will_launch($control);
57-
58-
foreach ($need_launch as $repository) {
59-
$name = $repository->getName();
60-
$callsign = $repository->getCallsign();
61-
$desc = "'{$name}' ({$callsign})";
62-
$phid = $repository->getPHID();
63-
64-
echo "Launching 'git fetch' daemon on the {$desc} repository...\n";
65-
$control->launchDaemon(
66-
'PhabricatorRepositoryGitFetchDaemon',
67-
array(
68-
$phid,
69-
));
70-
}
55+
exit(0);
7156
}
57+
58+
will_launch($control);
59+
$control->launchDaemon(
60+
'PhabricatorRepositoryPullLocalDaemon',
61+
array());
7262
break;
7363

7464
case 'repository-launch-master':
7565
$need_launch = phd_load_tracked_repositories();
7666
if (!$need_launch) {
7767
echo "There are no repositories with tracking enabled.\n";
68+
exit(1);
7869
} else {
7970
will_launch($control);
8071

72+
$control->launchDaemon(
73+
'PhabricatorRepositoryPullLocalDaemon',
74+
array());
75+
8176
foreach ($need_launch as $repository) {
8277
$name = $repository->getName();
8378
$callsign = $repository->getCallsign();
@@ -86,12 +81,6 @@ function must_have_extension($ext) {
8681

8782
switch ($repository->getVersionControlSystem()) {
8883
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
89-
echo "Launching 'git fetch' daemon on the {$desc} repository...\n";
90-
$control->launchDaemon(
91-
'PhabricatorRepositoryGitFetchDaemon',
92-
array(
93-
$phid,
94-
));
9584
echo "Launching discovery daemon on the {$desc} repository...\n";
9685
$control->launchDaemon(
9786
'PhabricatorRepositoryGitCommitDiscoveryDaemon',
@@ -108,12 +97,6 @@ function must_have_extension($ext) {
10897
));
10998
break;
11099
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
111-
echo "Launching 'hg pull' daemon on the {$desc} repository...\n";
112-
$control->launchDaemon(
113-
'PhabricatorRepositoryMercurialPullDaemon',
114-
array(
115-
$phid,
116-
));
117100
echo "Launching discovery daemon on the {$desc} repository...\n";
118101
$control->launchDaemon(
119102
'PhabricatorRepositoryMercurialCommitDiscoveryDaemon',
@@ -224,18 +207,6 @@ function must_have_extension($ext) {
224207
exit($err);
225208
}
226209

227-
function phd_load_tracked_repositories_of_type($type) {
228-
$repositories = phd_load_tracked_repositories();
229-
230-
foreach ($repositories as $key => $repository) {
231-
if ($repository->getVersionControlSystem() != $type) {
232-
unset($repositories[$key]);
233-
}
234-
}
235-
236-
return $repositories;
237-
}
238-
239210
function phd_load_tracked_repositories() {
240211
phutil_require_module(
241212
'phabricator',

scripts/repository/pull.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
/*
5+
* Copyright 2012 Facebook, Inc.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
$root = dirname(dirname(dirname(__FILE__)));
21+
require_once $root.'/scripts/__init_script__.php';
22+
23+
$args = new PhutilArgumentParser($argv);
24+
$args->setTagline('manually pull working copies');
25+
$args->setSynopsis(<<<EOHELP
26+
**pull.php** [__options__] __repository-callsign-or-phid ...__
27+
Manually pull/fetch working copies for the named repositories.
28+
EOHELP
29+
);
30+
$args->parseStandardArguments();
31+
$args->parse(
32+
array(
33+
array(
34+
'name' => 'repositories',
35+
'wildcard' => true,
36+
),
37+
));
38+
39+
$repo_names = $args->getArg('repositories');
40+
if (!$repo_names) {
41+
echo "Specify one or more repositories to pull, by callsign or PHID.\n";
42+
exit(1);
43+
}
44+
45+
$repos = PhabricatorRepository::loadAllByPHIDOrCallsign($repo_names);
46+
foreach ($repos as $repo) {
47+
$callsign = $repo->getCallsign();
48+
echo "Pulling '{$callsign}'...\n";
49+
PhabricatorRepositoryPullLocalDaemon::pullRepository($repo);
50+
}
51+
echo "Done.\n";

src/__phutil_library_map__.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -857,12 +857,10 @@
857857
'PhabricatorRepositoryGitCommitDiscoveryDaemon' => 'applications/repository/daemon/commitdiscovery/git',
858858
'PhabricatorRepositoryGitCommitDiscoveryDaemonTestCase' => 'applications/repository/daemon/commitdiscovery/git/__tests__',
859859
'PhabricatorRepositoryGitCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/git',
860-
'PhabricatorRepositoryGitFetchDaemon' => 'applications/repository/daemon/gitfetch',
861860
'PhabricatorRepositoryListController' => 'applications/repository/controller/list',
862861
'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/mercurial',
863862
'PhabricatorRepositoryMercurialCommitDiscoveryDaemon' => 'applications/repository/daemon/commitdiscovery/mercurial',
864863
'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/mercurial',
865-
'PhabricatorRepositoryMercurialPullDaemon' => 'applications/repository/daemon/mercurialpull',
866864
'PhabricatorRepositoryPullLocalDaemon' => 'applications/repository/daemon/pulllocal',
867865
'PhabricatorRepositoryShortcut' => 'applications/repository/storage/shortcut',
868866
'PhabricatorRepositorySvnCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/svn',
@@ -1752,13 +1750,11 @@
17521750
'PhabricatorRepositoryGitCommitDiscoveryDaemon' => 'PhabricatorRepositoryCommitDiscoveryDaemon',
17531751
'PhabricatorRepositoryGitCommitDiscoveryDaemonTestCase' => 'PhabricatorTestCase',
17541752
'PhabricatorRepositoryGitCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker',
1755-
'PhabricatorRepositoryGitFetchDaemon' => 'PhabricatorRepositoryPullLocalDaemon',
17561753
'PhabricatorRepositoryListController' => 'PhabricatorRepositoryController',
17571754
'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker',
17581755
'PhabricatorRepositoryMercurialCommitDiscoveryDaemon' => 'PhabricatorRepositoryCommitDiscoveryDaemon',
17591756
'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker',
1760-
'PhabricatorRepositoryMercurialPullDaemon' => 'PhabricatorRepositoryPullLocalDaemon',
1761-
'PhabricatorRepositoryPullLocalDaemon' => 'PhabricatorRepositoryDaemon',
1757+
'PhabricatorRepositoryPullLocalDaemon' => 'PhabricatorDaemon',
17621758
'PhabricatorRepositoryShortcut' => 'PhabricatorRepositoryDAO',
17631759
'PhabricatorRepositorySvnCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker',
17641760
'PhabricatorRepositorySvnCommitDiscoveryDaemon' => 'PhabricatorRepositoryCommitDiscoveryDaemon',

src/applications/repository/daemon/gitfetch/PhabricatorRepositoryGitFetchDaemon.php

Lines changed: 0 additions & 97 deletions
This file was deleted.

src/applications/repository/daemon/gitfetch/__init__.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/applications/repository/daemon/mercurialpull/PhabricatorRepositoryMercurialPullDaemon.php

Lines changed: 0 additions & 73 deletions
This file was deleted.

src/applications/repository/daemon/mercurialpull/__init__.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)