コード例 #1
0
 public static function registerErrorHandler()
 {
     // NOTE: This forces PhutilReadableSerializer to load, so that we are
     // able to handle errors which fire from inside autoloaders (PHP will not
     // reenter autoloaders).
     PhutilReadableSerializer::printableValue(null);
     PhutilErrorHandler::setErrorListener(array('DarkConsoleErrorLogPluginAPI', 'handleErrors'));
 }
コード例 #2
0
ファイル: index.php プロジェクト: rudimk/phabricator
 // Append any paths to $PATH if we need to.
 $paths = PhabricatorEnv::getEnvConfig('environment.append-paths');
 if (!empty($paths)) {
     $current_env_path = getenv('PATH');
     $new_env_paths = implode(':', $paths);
     putenv('PATH=' . $current_env_path . ':' . $new_env_paths);
 }
 // This is the earliest we can get away with this, we need env config first.
 PhabricatorAccessLog::init();
 $access_log = PhabricatorAccessLog::getLog();
 if ($access_log) {
     $access_log->setData(array('R' => idx($_SERVER, 'HTTP_REFERER', '-'), 'r' => idx($_SERVER, 'REMOTE_ADDR', '-'), 'M' => idx($_SERVER, 'REQUEST_METHOD', '-')));
 }
 DarkConsoleXHProfPluginAPI::hookProfiler();
 PhutilErrorHandler::initialize();
 PhutilErrorHandler::setErrorListener(array('DarkConsoleErrorLogPluginAPI', 'handleErrors'));
 foreach (PhabricatorEnv::getEnvConfig('load-libraries') as $library) {
     phutil_load_library($library);
 }
 if (PhabricatorEnv::getEnvConfig('phabricator.setup')) {
     try {
         PhabricatorSetup::runSetup();
     } catch (Exception $ex) {
         echo "EXCEPTION!\n";
         echo $ex;
     }
     return;
 }
 phabricator_detect_bad_base_uri();
 $translation = PhabricatorEnv::newObjectFromConfig('translation.provider');
 PhutilTranslator::getInstance()->setLanguage($translation->getLanguage())->addTranslations($translation->getTranslations());
コード例 #3
0
EOHELP
);
$args->parse(array(array('name' => 'trace', 'help' => pht('Enable debug tracing.')), array('name' => 'trace-memory', 'help' => pht('Enable debug memory tracing.')), array('name' => 'verbose', 'help' => pht('Enable verbose activity logging.')), array('name' => 'label', 'short' => 'l', 'param' => 'label', 'help' => pht('Optional process label. Makes "%s" nicer, no behavioral effects.', 'ps')), array('name' => 'daemon', 'wildcard' => true)));
$trace_memory = $args->getArg('trace-memory');
$trace_mode = $args->getArg('trace') || $trace_memory;
$verbose = $args->getArg('verbose');
if (function_exists('posix_isatty') && posix_isatty(STDIN)) {
    fprintf(STDERR, pht('Reading daemon configuration from stdin...') . "\n");
}
$config = @file_get_contents('php://stdin');
$config = id(new PhutilJSONParser())->parse($config);
PhutilTypeSpec::checkMap($config, array('log' => 'optional string|null', 'argv' => 'optional list<wild>', 'load' => 'optional list<string>', 'autoscale' => 'optional wild'));
$log = idx($config, 'log');
if ($log) {
    ini_set('error_log', $log);
    PhutilErrorHandler::setErrorListener(array('PhutilDaemon', 'errorListener'));
}
$load = idx($config, 'load', array());
foreach ($load as $library) {
    $library = Filesystem::resolvePath($library);
    phutil_load_library($library);
}
PhutilErrorHandler::initialize();
$daemon = $args->getArg('daemon');
if (!$daemon) {
    throw new PhutilArgumentUsageException(pht('Specify which class of daemon to start.'));
} else {
    if (count($daemon) > 1) {
        throw new PhutilArgumentUsageException(pht('Specify exactly one daemon to start.'));
    } else {
        $daemon = head($daemon);
コード例 #4
0
ファイル: exec_daemon.php プロジェクト: relrod/libphutil
}
PhutilErrorHandler::initialize();
function phutil_daemon_error_listener($event, $value, array $metadata)
{
    $message = idx($metadata, 'default_message');
    if ($message) {
        fwrite(STDERR, $message);
    }
}
if ($echo_to_stderr) {
    // If the caller has used "--log" to redirect the error log to a file, PHP
    // won't output it to stderr so the overseer can't capture it and won't
    // be able to send it to the web console. Install a listener which just echoes
    // errors to stderr, so we always get all the messages in the log and over
    // stdio, so they'll show up in the web console.
    PhutilErrorHandler::setErrorListener('phutil_daemon_error_listener');
}
$daemon = array_shift($argv);
if (!$daemon) {
    $args->printHelpAndExit();
}
$daemon = newv($daemon, array($argv));
if ($trace_mode) {
    $daemon->setTraceMode();
}
if ($trace_memory) {
    $daemon->setTraceMemory();
}
if ($verbose) {
    $daemon->setVerbose(true);
}