1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Send the aphlict process log to the node log

Summary: I've possibly seen a couple of `aphlict` processes exit under suspicious circumstances (maybe?). Make sure any PHP errors get captured into the log.

Test Plan:
  - Added an exception after forking.
  - Before change: vanished into thin air.
  - After change: visible in the log.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D15782
This commit is contained in:
epriestley 2016-04-21 16:58:25 -07:00
parent 43935d5916
commit 0f0105e783

View file

@ -301,7 +301,7 @@ abstract class PhabricatorAphlictManagementWorkflow
return $pid;
}
final public function cleanup($signo = '?') {
final public function cleanup($signo = null) {
global $g_future;
if ($g_future) {
$g_future->resolveKill();
@ -310,6 +310,11 @@ abstract class PhabricatorAphlictManagementWorkflow
Filesystem::remove($this->getPIDPath());
if ($signo !== null) {
$signame = phutil_get_signal_name($signo);
error_log("Caught signal {$signame}, exiting.");
}
exit(1);
}
@ -428,6 +433,15 @@ abstract class PhabricatorAphlictManagementWorkflow
$console = PhutilConsole::getConsole();
$this->willLaunch();
$log = $this->getOverseerLogPath();
if ($log !== null) {
echo tsprintf(
"%s\n",
pht(
'Writing logs to: %s',
$log));
}
$pid = pcntl_fork();
if ($pid < 0) {
throw new Exception(
@ -439,6 +453,12 @@ abstract class PhabricatorAphlictManagementWorkflow
exit(0);
}
// Redirect process errors to the error log. If we do not do this, any
// error the `aphlict` process itself encounters vanishes into thin air.
if ($log !== null) {
ini_set('error_log', $log);
}
// When we fork, the child process will inherit its parent's set of open
// file descriptors. If the parent process of bin/aphlict is waiting for
// bin/aphlict's file descriptors to close, it will be stuck waiting on
@ -529,4 +549,15 @@ abstract class PhabricatorAphlictManagementWorkflow
$server_argv);
}
private function getOverseerLogPath() {
// For now, just return the first log. We could refine this eventually.
$logs = idx($this->configData, 'logs', array());
foreach ($logs as $log) {
return $log['path'];
}
return null;
}
}