From 9e0a299b06c3223b6ba8ad17d4ae0aaae54dc595 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 23 Jul 2013 12:09:45 -0700 Subject: [PATCH] Launch daemons with a full Phabricator environment in the overseers Summary: Ref T1670. Prepare for the overseers to talk directly to the database instead of using Conduit. See T1670 for discussion. This shouldn't impact anything, except it has a very small chance of destabilizing the overseers. Test Plan: Ran `phd launch`, `phd debug`, `phd start`. Ran with `--trace-memory` and verified elevated but mostly steady memory usage (8MB / overseer). This climbed by 0.05KB / sec (4MB / day) but the source of the leaks seems to be the cURL calls we're making over Conduit so this will actually fix that. Disabling `--conduit-uri` reported steady memory usage. I wasn't able to identify anything leaking within code we control. This may be something like a dynamic but capped buffer in cURL, since we haven't seen any issues in the wild. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1670 Differential Revision: https://secure.phabricator.com/D6534 --- bin/phd | 2 +- scripts/daemon/launch_daemon.php | 27 +++++++++++++++++++ ...daemon_launcher.php => manage_daemons.php} | 0 scripts/daemon/phd-daemon | 1 + .../PhabricatorDaemonManagementWorkflow.php | 20 +++----------- 5 files changed, 33 insertions(+), 17 deletions(-) create mode 100755 scripts/daemon/launch_daemon.php rename scripts/daemon/{phabricator_daemon_launcher.php => manage_daemons.php} (100%) create mode 120000 scripts/daemon/phd-daemon diff --git a/bin/phd b/bin/phd index f1945da552..101465cd29 120000 --- a/bin/phd +++ b/bin/phd @@ -1 +1 @@ -../scripts/daemon/phabricator_daemon_launcher.php \ No newline at end of file +../scripts/daemon/manage_daemons.php \ No newline at end of file diff --git a/scripts/daemon/launch_daemon.php b/scripts/daemon/launch_daemon.php new file mode 100755 index 0000000000..21214fecb7 --- /dev/null +++ b/scripts/daemon/launch_daemon.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +getAllLibraries() as $library) { + if ($library == 'phutil') { + // No need to load libphutil, it's necessarily loaded implicitly by the + // daemon itself. + continue; + } + $flags[] = '--load-phutil-library='.phutil_get_library_root($library); +} + +// Add more flags. +array_splice($argv, 2, 0, $flags); + +$overseer = new PhutilDaemonOverseer($argv); +$overseer->run(); diff --git a/scripts/daemon/phabricator_daemon_launcher.php b/scripts/daemon/manage_daemons.php similarity index 100% rename from scripts/daemon/phabricator_daemon_launcher.php rename to scripts/daemon/manage_daemons.php diff --git a/scripts/daemon/phd-daemon b/scripts/daemon/phd-daemon new file mode 120000 index 0000000000..26441218dc --- /dev/null +++ b/scripts/daemon/phd-daemon @@ -0,0 +1 @@ +launch_daemon.php \ No newline at end of file diff --git a/src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php b/src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php index 67eaacb756..0c2062de6b 100644 --- a/src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php +++ b/src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php @@ -131,18 +131,6 @@ abstract class PhabricatorDaemonManagementWorkflow $flags[] = '--daemonize'; } - $bootloader = PhutilBootloader::getInstance(); - foreach ($bootloader->getAllLibraries() as $library) { - if ($library == 'phutil') { - // No need to load libphutil, it's necessarily loaded implicitly by the - // daemon itself. - continue; - } - $flags[] = csprintf( - '--load-phutil-library=%s', - phutil_get_library_root($library)); - } - $flags[] = csprintf('--conduit-uri=%s', PhabricatorEnv::getURI('/api/')); if (!$debug) { @@ -160,13 +148,13 @@ abstract class PhabricatorDaemonManagementWorkflow $flags[] = csprintf('--phd=%s', $pid_dir); $command = csprintf( - './launch_daemon.php %s %C %C', + './phd-daemon %s %C %C', $daemon, implode(' ', $flags), implode(' ', $argv)); - $libphutil_root = dirname(phutil_get_library_root('phutil')); - $daemon_script_dir = $libphutil_root.'/scripts/daemon/'; + $phabricator_root = dirname(phutil_get_library_root('phabricator')); + $daemon_script_dir = $phabricator_root.'/scripts/daemon/'; if ($debug) { // Don't terminate when the user sends ^C; it will be sent to the @@ -175,7 +163,7 @@ abstract class PhabricatorDaemonManagementWorkflow SIGINT, array(__CLASS__, 'ignoreSignal')); - echo "\n libphutil/scripts/daemon/ \$ {$command}\n\n"; + echo "\n phabricator/scripts/daemon/ \$ {$command}\n\n"; phutil_passthru('(cd %s && exec %C)', $daemon_script_dir, $command); } else {