Skip to content

Commit b800df8

Browse files
author
epriestley
committedMay 9, 2012
Simplify daemon management: "phd start"
Summary: - Merge CommitTask daemon into PullLocal daemon. This is another artifact of past instability (and order-dependent parsers). We still publish to the timeline, although this was the last consumer. Long term we'll probably delete timeline and move to webhooks, since everyone who has asked about this stuff has been eager to trade away the durability and ordering of the timeline for the ease of use of webhooks. There's also no reason to timeline this anymore since parsing is no longer order-dependent. - Add `phd start` to start all the daemons you need. Add `phd restart` to restart all the daemons you need. So cool~ - Simplify and improve phd and Diffusion daemon documentation. Test Plan: - Ran `phd start`. - Ran `phd restart`. - Generated/read documentation. - Imported some stuff, got clean parses. Reviewers: btrahan, csilvers Reviewed By: csilvers CC: aran, jungejason, nh Differential Revision: https://secure.phabricator.com/D2433
1 parent 907f1a3 commit b800df8

File tree

11 files changed

+229
-192
lines changed

11 files changed

+229
-192
lines changed
 

‎conf/default.conf.php

+5
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,11 @@
937937
// track running daemons.
938938
'phd.pid-directory' => '/var/tmp/phd',
939939

940+
// Number of "TaskMaster" daemons that "phd start" should start. You can
941+
// raise this if you have a task backlog, or explicitly launch more with
942+
// "phd launch <N> taskmaster".
943+
'phd.start-taskmasters' => 4,
944+
940945
// This value is an input to the hash function when building resource hashes.
941946
// It has no security value, but if you accidentally poison user caches (by
942947
// pushing a bad patch or having something go wrong with a CDN, e.g.) you can

‎scripts/daemon/phabricator_daemon_launcher.php

+53-11
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ function must_have_extension($ext) {
3434
}
3535
}
3636

37-
switch (isset($argv[1]) ? $argv[1] : 'help') {
37+
$command = isset($argv[1]) ? $argv[1] : 'help';
38+
switch ($command) {
3839
case 'list':
3940
$err = $control->executeListCommand();
4041
exit($err);
@@ -48,7 +49,45 @@ function must_have_extension($ext) {
4849
$err = $control->executeStopCommand($pass_argv);
4950
exit($err);
5051

51-
case 'repository-launch-readonly':
52+
case 'restart':
53+
$err = $control->executeStopCommand(array());
54+
if ($err) {
55+
exit($err);
56+
}
57+
/* Fall Through */
58+
case 'start':
59+
$running = $control->loadRunningDaemons();
60+
if ($running) {
61+
echo phutil_console_wrap(
62+
"phd start: Unable to start daemons because daemons are already ".
63+
"running.\n".
64+
"You can view running daemons with 'phd list'.\n".
65+
"You can stop running daemons with 'phd stop'.\n".
66+
"You can use 'phd restart' to stop all daemons before starting new ".
67+
"daemons.\n");
68+
exit(1);
69+
}
70+
71+
$daemons = array(
72+
array('PhabricatorRepositoryPullLocalDaemon', array()),
73+
array('PhabricatorGarbageCollectorDaemon', array()),
74+
);
75+
76+
$taskmasters = PhabricatorEnv::getEnvConfig('phd.start-taskmasters');
77+
for ($ii = 0; $ii < $taskmasters; $ii++) {
78+
$daemons[] = array('PhabricatorTaskmasterDaemon', array());
79+
}
80+
81+
will_launch($control);
82+
foreach ($daemons as $spec) {
83+
list($name, $argv) = $spec;
84+
echo "Launching '{$name}'...\n";
85+
$control->launchDaemon($name, $argv);
86+
}
87+
88+
echo "Done.\n";
89+
break;
90+
5291
$need_launch = phd_load_tracked_repositories();
5392
if (!$need_launch) {
5493
echo "There are no repositories with tracking enabled.\n";
@@ -68,7 +107,16 @@ function must_have_extension($ext) {
68107
echo "Done.\n";
69108
break;
70109

110+
case 'repository-launch-readonly':
71111
case 'repository-launch-master':
112+
if ($command == 'repository-launch-readonly') {
113+
$daemon_args = array(
114+
'--no-discovery',
115+
);
116+
} else {
117+
$daemon_args = array();
118+
}
119+
72120
$need_launch = phd_load_tracked_repositories();
73121
if (!$need_launch) {
74122
echo "There are no repositories with tracking enabled.\n";
@@ -77,18 +125,12 @@ function must_have_extension($ext) {
77125

78126
will_launch($control);
79127

80-
echo "Launching PullLocal daemon in master mode...\n";
128+
echo "Launching PullLocal daemon...\n";
81129
$control->launchDaemon(
82130
'PhabricatorRepositoryPullLocalDaemon',
83-
array());
84-
85-
echo "Launching CommitTask daemon...\n";
86-
$control->launchDaemon(
87-
'PhabricatorRepositoryCommitTaskDaemon',
88-
array());
131+
$daemon_args);
89132

90-
echo "NOTE: Make sure you run some taskmaster daemons too, e.g. ".
91-
"with 'phd launch 4 taskmaster'.\n";
133+
echo "NOTE: '{$command}' is deprecated. Consult the documentation.\n";
92134

93135
echo "Done.\n";
94136
break;

‎scripts/install/update_phabricator.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ sudo /etc/init.d/httpd start
5757
# Restart daemons. Customize this to start whatever daemons you're running on
5858
# your system.
5959

60-
# $ROOT/phabricator/bin/phd repository-launch-master
61-
# $ROOT/phabricator/bin/phd launch garbagecollector
62-
# $ROOT/phabricator/bin/phd launch 4 taskmaster
60+
$ROOT/phabricator/bin/phd start
6361
# $ROOT/phabricator/bin/phd launch ircbot /config/bot.json
6462

6563

‎src/__phutil_library_map__.php

-2
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,6 @@
845845
'PhabricatorRepositoryCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/base',
846846
'PhabricatorRepositoryCommitOwnersWorker' => 'applications/repository/worker/owner',
847847
'PhabricatorRepositoryCommitParserWorker' => 'applications/repository/worker/base',
848-
'PhabricatorRepositoryCommitTaskDaemon' => 'applications/repository/daemon/committask',
849848
'PhabricatorRepositoryController' => 'applications/repository/controller/base',
850849
'PhabricatorRepositoryCreateController' => 'applications/repository/controller/create',
851850
'PhabricatorRepositoryDAO' => 'applications/repository/storage/base',
@@ -1734,7 +1733,6 @@
17341733
'PhabricatorRepositoryCommitMessageParserWorker' => 'PhabricatorRepositoryCommitParserWorker',
17351734
'PhabricatorRepositoryCommitOwnersWorker' => 'PhabricatorRepositoryCommitParserWorker',
17361735
'PhabricatorRepositoryCommitParserWorker' => 'PhabricatorWorker',
1737-
'PhabricatorRepositoryCommitTaskDaemon' => 'PhabricatorDaemon',
17381736
'PhabricatorRepositoryController' => 'PhabricatorController',
17391737
'PhabricatorRepositoryCreateController' => 'PhabricatorRepositoryController',
17401738
'PhabricatorRepositoryDAO' => 'PhabricatorLiskDAO',

‎src/applications/repository/daemon/committask/PhabricatorRepositoryCommitTaskDaemon.php

-80
This file was deleted.

‎src/applications/repository/daemon/committask/__init__.php

-19
This file was deleted.

‎src/applications/repository/daemon/pulllocal/PhabricatorRepositoryPullLocalDaemon.php

+32
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,16 @@ private static function recordCommit(
269269

270270
try {
271271
$commit->save();
272+
272273
$event = new PhabricatorTimelineEvent(
273274
'cmit',
274275
array(
275276
'id' => $commit->getID(),
276277
));
277278
$event->recordEvent();
278279

280+
self::insertTask($repository, $commit);
281+
279282
queryfx(
280283
$repository->establishConnection('w'),
281284
'INSERT INTO %T (repositoryID, size, lastCommitID, epoch)
@@ -300,6 +303,35 @@ private static function recordCommit(
300303
}
301304
}
302305

306+
private static function insertTask(
307+
PhabricatorRepository $repository,
308+
PhabricatorRepositoryCommmit $commit) {
309+
310+
$vcs = $repository->getVersionControlSystem();
311+
switch ($vcs) {
312+
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
313+
$class = 'PhabricatorRepositoryGitCommitMessageParserWorker';
314+
break;
315+
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
316+
$class = 'PhabricatorRepositorySvnCommitMessageParserWorker';
317+
break;
318+
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
319+
$class = 'PhabricatorRepositoryMercurialCommitMessageParserWorker';
320+
break;
321+
default:
322+
throw new Exception("Unknown repository type '{$vcs}'!");
323+
}
324+
325+
$task = new PhabricatorWorkerTask();
326+
$task->setTaskClass($class);
327+
$task->setData(
328+
array(
329+
'commitID' => $commit->getID(),
330+
));
331+
$task->save();
332+
}
333+
334+
303335
private static function setCache(
304336
PhabricatorRepository $repository,
305337
$commit_identifier) {

‎src/applications/repository/daemon/pulllocal/__init__.php

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
phutil_require_module('phabricator', 'applications/repository/storage/repository');
1616
phutil_require_module('phabricator', 'infrastructure/daemon/base');
1717
phutil_require_module('phabricator', 'infrastructure/daemon/timeline/storage/event');
18+
phutil_require_module('phabricator', 'infrastructure/daemon/workers/storage/task');
1819
phutil_require_module('phabricator', 'storage/queryfx');
1920

2021
phutil_require_module('phutil', 'error');

0 commit comments

Comments
 (0)
Failed to load comments.