@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+32 -1
+32 -1
src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php
··· 301 301 return $pid; 302 302 } 303 303 304 - final public function cleanup($signo = '?') { 304 + final public function cleanup($signo = null) { 305 305 global $g_future; 306 306 if ($g_future) { 307 307 $g_future->resolveKill(); ··· 309 309 } 310 310 311 311 Filesystem::remove($this->getPIDPath()); 312 + 313 + if ($signo !== null) { 314 + $signame = phutil_get_signal_name($signo); 315 + error_log("Caught signal {$signame}, exiting."); 316 + } 312 317 313 318 exit(1); 314 319 } ··· 428 433 $console = PhutilConsole::getConsole(); 429 434 $this->willLaunch(); 430 435 436 + $log = $this->getOverseerLogPath(); 437 + if ($log !== null) { 438 + echo tsprintf( 439 + "%s\n", 440 + pht( 441 + 'Writing logs to: %s', 442 + $log)); 443 + } 444 + 431 445 $pid = pcntl_fork(); 432 446 if ($pid < 0) { 433 447 throw new Exception( ··· 439 453 exit(0); 440 454 } 441 455 456 + // Redirect process errors to the error log. If we do not do this, any 457 + // error the `aphlict` process itself encounters vanishes into thin air. 458 + if ($log !== null) { 459 + ini_set('error_log', $log); 460 + } 461 + 442 462 // When we fork, the child process will inherit its parent's set of open 443 463 // file descriptors. If the parent process of bin/aphlict is waiting for 444 464 // bin/aphlict's file descriptors to close, it will be stuck waiting on ··· 527 547 $this->getNodeArgv(), 528 548 $this->getAphlictScriptPath(), 529 549 $server_argv); 550 + } 551 + 552 + private function getOverseerLogPath() { 553 + // For now, just return the first log. We could refine this eventually. 554 + $logs = idx($this->configData, 'logs', array()); 555 + 556 + foreach ($logs as $log) { 557 + return $log['path']; 558 + } 559 + 560 + return null; 530 561 } 531 562 532 563 }