Exemple #1
0
<?php

/**
 * dagger项目初始化
 */
session_start();
ob_start();
//用户配置
require DAGGER_PATH_ROOT . 'config/SysInitConfig.php';
//系统配置
require DAGGER_PATH_ROOT . 'libs/DaggerSysInitConfig.php';
//__autoload函数
require DAGGER_PATH_LIBS . 'basics.php';
//载入数据存储配置
require DAGGER_PATH_CONFIG . 'DBConfig.php';
if (1 === DAGGER_XHPROF && defined('DAGGER_ALARM_XHPROF_API')) {
    xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
    define('DAGGER_XHPROF_ID', uniqid());
}
//静态URL解析规则
BaseModelRouter::route();
$class = BaseModelCommon::getFormatName($_GET[DAGGER_CONTROLLER], 'class');
$class .= 'Controller';
$controller = new $class($_GET[DAGGER_CONTROLLER], $_GET[DAGGER_ACTION]);
$controller->runCommand();
if (defined('DAGGER_XHPROF') && 1 === DAGGER_XHPROF) {
    echo '<br /><a href="' . BaseModelDebug::getXhprofUrl() . '" target="_blank" >xhprof</a>';
}
Exemple #2
0
/**
 * 在firephp中捕获fatal异常,用以display_error
 * 不开的情况下调试网站
 */
function daggerShutDown()
{
    if (!defined('QUEUE')) {
        // 超时报警
        $runtime = floatval(BaseModelCommon::getRunTime());
        $timeout = DAGGER_TIMEOUT;
        if ($runtime > $timeout) {
            $statInfo = BaseModelCommon::getStatInfo();
            BaseModelLog::sendLog(90106, "[run:{$runtime}s]" . "[db:({$statInfo['db']['count']}次{$statInfo['db']['time']}ms)]" . "[mc:({$statInfo['mc']['count']}次{$statInfo['mc']['time']}ms)]" . "[request:({$statInfo['request']['count']}次{$statInfo['request']['time']}ms)]" . "[redis:({$statInfo['redis']['count']}次{$statInfo['redis']['time']}ms)]", '', BaseModelLog::ERROR_MODEL_ID_PHP);
            1 === DAGGER_DEBUG && BaseModelCommon::debug("当前脚本运行[{$runtime}],大于{$timeout}秒", 'timeout_error');
        }
    }
    //xhprof
    if (defined('DAGGER_XHPROF_ID')) {
        BaseModelCommon::debug(BaseModelDebug::getXhprofUrl(), 'xhprof_url');
    }
    // all_info的debug信息
    if (1 === DAGGER_DEBUG) {
        $statInfo = BaseModelCommon::getStatInfo();
        BaseModelCommon::debug(array(array('资源', '次数', '消耗时间(ms)'), array('sql', $statInfo['db']['count'] . ' 次', $statInfo['db']['time'] . ' ms'), array('request', $statInfo['request']['count'] . ' 次', $statInfo['request']['time'] . ' ms'), array('mc', $statInfo['mc']['count'] . ' 次', $statInfo['mc']['time'] . ' ms'), array('redis', $statInfo['redis']['count'] . ' 次', $statInfo['redis']['time'] . ' ms'), array('总运行时间', '', BaseModelCommon::getRunTime())), 'all_info');
        empty(BaseModelCommon::$debugTypeFilter) || BaseModelCommon::debug('部分debug信息被隐藏,规则:' . BaseModelCommon::$debugTypeFilter, 'filter_info');
        BaseModelCommon::debug(DAGGER_VERSION, 'dagger_version');
    }
    if (!defined('QUEUE')) {
        // 在线调试
        if (1 === DAGGER_ONLINE_DEBUG) {
            BaseModelCommon::sendOnlineDebug();
        }
        ob_end_flush();
    }
    $error = error_get_last();
    if (empty($error) || !(E_ERROR & $error['type'])) {
        // This error code is not included in error_reporting
        defined('QUEUE_CTL') && QueueTaskCtl::end(0, '');
        return false;
    }
    formatErrorInfo($error['type'], $error['message'], $error['file'], $error['line']);
    defined('QUEUE_CTL') && QueueTaskCtl::end(1, $error['message']);
    return true;
}