PHP脚本执行时间耗时预警
public bool Asf_Application::setTimeoutHandler(callable $timeout_handler)
callable
设置成功返回 true, 否则会有异常信息提示
<?php function myTimeoutHandler($errno, $errstr) { var_dump($errno, $errstr); /* int(976) string(44) "/index/redis executing too slow 0.208992 sec" */ } $handle = new Asf\Application($configs); $handle->setTimeoutHandler('myTimeoutHandler'); $handle->run();
<?php class Debug { public static function myTimeoutHandler($errno, $errstr) { } } $handle = new Asf\Application($configs); $handle->setTimeoutHandler(array('Debug', 'myTimeoutHandler')); $handle->run();
<?php class Debug { public function myTimeoutHandler($errno, $errstr) { } } $handler = new Debug(); $handle = new Asf\Application($configs); $handle->setTimeoutHandler(array($handler, 'myTimeoutHandler')); $handle->run();
<?php class Bootstrap { public function _initAlarm() { $app = Asf\Application::getInstance(); $app->setTimeoutHandler(array($this, 'timeoutAlarm')); } public function timeoutAlarm($errno, $errstr) { } } $handle = new Asf\Application($configs); $handle->bootstrap()->run();