Skip to content

Commit b61e325

Browse files
author
epriestley
committed
Show logs to the console in 'phd debug'
Summary: Currently we send logs to the logfile in 'phd debug', but we should send them to the console instead. Also fixed some %C stuff which could theoretically cause problems if a user had percentage symbols in their paths (heaven forbid). fratrik, this or D535 might have been involved in frustrating your efforts to debug the "sudo" stuff. Test Plan: Ran "phd debug irc derpderp" and "phd launch irc derpderp". In the former case, the exception appeared in the console. In the latter, it appeared in the log. Reviewed By: codeblock Reviewers: codeblock, jungejason, tuomaspelkonen, aran, fratrik CC: aran, codeblock Differential Revision: 536
1 parent 451b0e0 commit b61e325

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

scripts/daemon/phabricator_daemon_launcher.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,15 @@
163163
$daemon = reset($match);
164164
}
165165

166-
will_launch($control);
166+
$with_logs = true;
167+
if ($is_debug) {
168+
// In debug mode, we emit errors straight to stdout, so nothing useful
169+
// will show up in the logs. Don't echo the message about stuff showing
170+
// up in them, since it would be confusing.
171+
$with_logs = false;
172+
}
173+
174+
will_launch($control, $with_logs);
167175

168176
if ($is_debug) {
169177
echo "Launching {$daemon} in debug mode (nondaemonized)...\n";
@@ -217,10 +225,12 @@ function phd_load_tracked_repositories() {
217225
return $repositories;
218226
}
219227

220-
function will_launch($control) {
228+
function will_launch($control, $with_logs = true) {
221229
echo "Staging launch...\n";
222230
$control->pingConduit();
223-
$log_dir = $control->getControlDirectory('log').'/daemons.log';
224-
echo "NOTE: Logs will appear in '{$log_dir}'.\n\n";
231+
if ($with_logs) {
232+
$log_dir = $control->getControlDirectory('log').'/daemons.log';
233+
echo "NOTE: Logs will appear in '{$log_dir}'.\n\n";
234+
}
225235
}
226236

src/infrastructure/daemon/control/PhabricatorDaemonControl.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,24 @@ public function launchDaemon($daemon, array $argv, $debug = false) {
216216
"./launch_daemon.php ".
217217
"%s ".
218218
"--load-phutil-library=%s ".
219-
implode(' ', $extra_libraries)." ".
219+
"%C ".
220220
"--conduit-uri=%s ".
221221
"--phd=%s ".
222-
"--log=%s ".
223-
($debug ? '--trace ' : '--daemonize ').
224-
implode(' ', $argv),
222+
($debug ? '--trace ' : '--daemonize '),
225223
$daemon,
226224
phutil_get_library_root('phabricator'),
225+
implode(' ', $extra_libraries),
227226
PhabricatorEnv::getURI('/api/'),
228-
$pid_dir,
229-
$log_dir);
227+
$pid_dir);
228+
229+
if (!$debug) {
230+
// If we're running "phd debug", send output straight to the console
231+
// instead of to a logfile.
232+
$command = csprintf("%C --log=%s", $command, $log_dir);
233+
}
234+
235+
// Append the daemon's argv.
236+
$command = csprintf("%C %C", $command, implode(' ', $argv));
230237

231238
if ($debug) {
232239
// Don't terminate when the user sends ^C; it will be sent to the

0 commit comments

Comments
 (0)