pull/637/head
Mr Chen 5 months ago
parent 8e4e9ddf62
commit f98a7298c5
  1. 55
      plugins/php/conf/app_start.php
  2. 1
      plugins/xhprof/index.py

@ -1,7 +1,7 @@
<?php <?php
if (isset($_GET['mw_opcache_reset']) && $_GET['mw_opcache_reset'] == 'ok'){ if (isset($_GET['mw_opcache_reset']) && $_GET['mw_opcache_reset'] == 'ok') {
opcache_reset(); opcache_reset();
} }
define('XHProf_Name', 'mdd'); define('XHProf_Name', 'mdd');
@ -11,43 +11,42 @@ define('XHProf_Name', 'mdd');
*/ */
function app_xhprof_start() { function app_xhprof_start() {
$root = '{$ROOT_PATH}'; $root = '{$ROOT_PATH}';
$lib = $root . '/server/xhprof/xhprof_lib/utils/xhprof_lib.php'; $lib = $root . '/server/xhprof/xhprof_lib/utils/xhprof_lib.php';
if (file_exists($lib)) { if (file_exists($lib)) {
include_once $lib; include_once $lib;
include_once $root . '/server/xhprof/xhprof_lib/utils/xhprof_runs.php'; include_once $root . '/server/xhprof/xhprof_lib/utils/xhprof_runs.php';
xhprof_enable(); xhprof_enable();
} }
} }
function app_xhprof_end() { function app_xhprof_end() {
$root = '{$ROOT_PATH}'; $root = '{$ROOT_PATH}';
$lib = $root . '/server/xhprof'; $lib = $root . '/server/xhprof';
if (!file_exists($lib)) { if (! file_exists($lib)) {
return; return;
} }
//保存xhprof数据 //保存xhprof数据
$xhprof_data = xhprof_disable(); $xhprof_data = xhprof_disable();
$xhprof_runs = new XHProfRuns_Default(); $xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, 'xhprof_foo'); $run_id = $xhprof_runs->save_run($xhprof_data, 'xhprof_foo');
$profiler_url = sprintf('http://{$LOCAL_IP}:5858/index.php?run=%s&source=xhprof_foo', $run_id); $profiler_url = sprintf('http://{$LOCAL_IP}:5858/index.php?run=%s&source=xhprof_foo', $run_id);
echo "<script language='javascript'>window.open('{$profiler_url}')</script>"; echo "<script language='javascript'>window.open('{$profiler_url}')</script>";
// echo '<a href="' . $profiler_url . '" target="_blank">Profiler output</a>'; // echo '<a href="' . $profiler_url . '" target="_blank">Profiler output</a>';
} }
if (extension_loaded('xhprof') if (extension_loaded('xhprof')
&& isset($_GET[XHProf_Name]) && $_GET[XHProf_Name] == 'ok' && && isset($_GET[XHProf_Name]) && $_GET[XHProf_Name] == 'ok' &&
(!in_array($_SERVER['SCRIPT_NAME'], array('/xhprof_html/callgraph.php', (! in_array($_SERVER['SCRIPT_NAME'], ['/xhprof_html/callgraph.php',
'/xhprof_html/index.php')))) { '/xhprof_html/index.php']))) {
app_xhprof_start(); app_xhprof_start();
include_once $_SERVER['SCRIPT_FILENAME']; register_shutdown_function('app_xhprof_end');
app_xhprof_end(); include_once $_SERVER['SCRIPT_FILENAME'];
exit;
} }
?> ?>

@ -165,7 +165,6 @@ def setPhpVer():
mw.writeFile(file_run, centent) mw.writeFile(file_run, centent)
mw.restartWeb() mw.restartWeb()
return 'ok' return 'ok'

Loading…
Cancel
Save