mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 15:21:03 +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:
parent
43935d5916
commit
0f0105e783
1 changed files with 32 additions and 1 deletions
|
@ -301,7 +301,7 @@ abstract class PhabricatorAphlictManagementWorkflow
|
||||||
return $pid;
|
return $pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function cleanup($signo = '?') {
|
final public function cleanup($signo = null) {
|
||||||
global $g_future;
|
global $g_future;
|
||||||
if ($g_future) {
|
if ($g_future) {
|
||||||
$g_future->resolveKill();
|
$g_future->resolveKill();
|
||||||
|
@ -310,6 +310,11 @@ abstract class PhabricatorAphlictManagementWorkflow
|
||||||
|
|
||||||
Filesystem::remove($this->getPIDPath());
|
Filesystem::remove($this->getPIDPath());
|
||||||
|
|
||||||
|
if ($signo !== null) {
|
||||||
|
$signame = phutil_get_signal_name($signo);
|
||||||
|
error_log("Caught signal {$signame}, exiting.");
|
||||||
|
}
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,6 +433,15 @@ abstract class PhabricatorAphlictManagementWorkflow
|
||||||
$console = PhutilConsole::getConsole();
|
$console = PhutilConsole::getConsole();
|
||||||
$this->willLaunch();
|
$this->willLaunch();
|
||||||
|
|
||||||
|
$log = $this->getOverseerLogPath();
|
||||||
|
if ($log !== null) {
|
||||||
|
echo tsprintf(
|
||||||
|
"%s\n",
|
||||||
|
pht(
|
||||||
|
'Writing logs to: %s',
|
||||||
|
$log));
|
||||||
|
}
|
||||||
|
|
||||||
$pid = pcntl_fork();
|
$pid = pcntl_fork();
|
||||||
if ($pid < 0) {
|
if ($pid < 0) {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
|
@ -439,6 +453,12 @@ abstract class PhabricatorAphlictManagementWorkflow
|
||||||
exit(0);
|
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
|
// 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
|
// 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
|
// bin/aphlict's file descriptors to close, it will be stuck waiting on
|
||||||
|
@ -529,4 +549,15 @@ abstract class PhabricatorAphlictManagementWorkflow
|
||||||
$server_argv);
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue