Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add `--verbose` support to phd

Summary:
Support the `--verbose` flag added in D2795 in `phd`. See T1389.

Also simplify argument generation a little bit.

Test Plan: Ran "nice" daemon with debug,  daemon + verbose, daemon + no verbose.

Reviewers: vrana, jungejason, edward, aurelijus

Reviewed By: aurelijus

CC: aran

Maniphest Tasks: T1389

Differential Revision: https://secure.phabricator.com/D2797
  • Loading branch information...
commit fabe52335e05cd82a48bba2c11a6837fc4b4544c 1 parent d4b6b09
@epriestley epriestley authored
View
10 conf/default.conf.php
@@ -1024,6 +1024,16 @@
// "phd launch <N> taskmaster".
'phd.start-taskmasters' => 4,
+ // Launch daemons in "verbose" mode by default. This creates a lot of output,
+ // but can help debug issues. Daemons launched in debug mode with "phd debug"
+ // are always launched in verbose mode. See also 'phd.trace'.
+ 'phd.verbose' => false,
+
+ // Launch daemons in "trace" mode by default. This creates an ENORMOUS amount
+ // of output, but can help debug issues. Daemons launched in debug mode with
+ // "phd debug" are always launched in trace mdoe. See also 'phd.verbose'.
+ 'phd.trace' => false,
+
// Path to custom celerity resource map relative to 'phabricator/src'.
// See also `scripts/celerity_mapper.php`.
'celerity.resource-path' => '__celerity_resource_map__.php',
View
70 src/infrastructure/daemon/PhabricatorDaemonControl.php
@@ -208,57 +208,59 @@ public function launchDaemon($daemon, array $argv, $debug = false) {
"Daemon '{$daemon}' is not loaded, misspelled or abstract.");
}
- $pid_dir = $this->getControlDirectory('pid');
- $log_dir = $this->getControlDirectory('log').'/daemons.log';
-
$libphutil_root = dirname(phutil_get_library_root('phutil'));
$launch_daemon = $libphutil_root.'/scripts/daemon/';
- // TODO: This should be a much better user experience.
- Filesystem::assertExists($pid_dir);
- Filesystem::assertIsDirectory($pid_dir);
- Filesystem::assertWritable($pid_dir);
-
foreach ($argv as $key => $arg) {
$argv[$key] = escapeshellarg($arg);
}
- $bootloader = PhutilBootloader::getInstance();
- $all_libraries = $bootloader->getAllLibraries();
+ $flags = array();
+ if ($debug || PhabricatorEnv::getEnvConfig('phd.trace')) {
+ $flags[] = '--trace';
+ }
- $non_default_libraries = array_diff(
- $all_libraries,
- array('phutil', 'phabricator'));
+ if ($debug || PhabricatorEnv::getEnvConfig('phd.verbose')) {
+ $flags[] = '--verbose';
+ }
- $extra_libraries = array();
- foreach ($non_default_libraries as $library) {
- $extra_libraries[] = csprintf(
+ if (!$debug) {
+ $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));
}
- $command = csprintf(
- "./launch_daemon.php ".
- "%s ".
- "--load-phutil-library=%s ".
- "%C ".
- "--conduit-uri=%s ".
- "--phd=%s ".
- ($debug ? '--trace ' : '--daemonize '),
- $daemon,
- phutil_get_library_root('phabricator'),
- implode(' ', $extra_libraries),
- PhabricatorEnv::getURI('/api/'),
- $pid_dir);
+ $flags[] = csprintf('--conduit-uri=%s', PhabricatorEnv::getURI('/api/'));
if (!$debug) {
- // If we're running "phd debug", send output straight to the console
- // instead of to a logfile.
- $command = csprintf("%C --log=%s", $command, $log_dir);
+ $log_dir = $this->getControlDirectory('log').'/daemons.log';
+ $flags[] = csprintf('--log=%s', $log_dir);
}
- // Append the daemon's argv.
- $command = csprintf("%C %C", $command, implode(' ', $argv));
+ $pid_dir = $this->getControlDirectory('pid');
+
+ // TODO: This should be a much better user experience.
+ Filesystem::assertExists($pid_dir);
+ Filesystem::assertIsDirectory($pid_dir);
+ Filesystem::assertWritable($pid_dir);
+
+ $flags[] = csprintf('--phd=%s', $pid_dir);
+
+ $command = csprintf(
+ './launch_daemon.php %s %C %C',
+ $daemon,
+ implode(' ', $flags),
+ implode(' ', $argv));
if ($debug) {
// Don't terminate when the user sends ^C; it will be sent to the
Please sign in to comment.
Something went wrong with that request. Please try again.