diff --git a/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php b/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php --- a/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php +++ b/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php @@ -301,7 +301,7 @@ 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 @@ 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 @@ $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 @@ 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 @@ $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; + } + }