Exemplo n.º 1
0
 public static function setSession($name, $val)
 {
     if (false == self::$_sessionStart) {
         session_start();
         self::$_sessionStart = true;
     }
     $_SESSION[$name] = $val;
 }
Exemplo n.º 2
0
 /**
  * 全局异常处理
  * 异常有两个来源
  * 1. 通过set_exception_handler设置的全局未捕获异常
  * 2. 通过Core_App::dispatch()捕获的异常
  * @param  [type] $e [description]
  * @return [type]    [description]
  */
 public function handleException($e)
 {
     $controller = Core_App::getInstance()->controllerObj;
     $isBaseExp = $e instanceof Exception_Base;
     $info = array('exp' => get_class($e), 'code' => $e->getCode(), 'msg' => $e->getMessage(), 'expParams' => $isBaseExp ? $e->getParams() : null, 'line' => sprintf('%s:%d', $e->getFile(), $e->getLine()), 'uri' => Comm_Context::getServer('REQUEST_URI'), 'elapse' => sprintf('%.3f', microtime(true) - SYSTEM_START_TIME), 'reqParams' => empty($controller) ? null : $controller->getParams());
     Tool_Log::error('request exception, ' . Tool_Json::encode($info));
     if ($isBaseExp) {
         // 异常自身处理过程
         $e->handle();
     } else {
         // 默认异常处理过程
         $a = new Exception_Base();
         $a->__real__ = $e;
         $a->handle();
     }
 }
Exemplo n.º 3
0
<?php

/**
 * 默认的app设置
 * @author hitzheng
 */
return array('name' => 'app', 'log_level' => 'PRO' == Comm_Context::getServer('APP_ENV', 'DEV') ? 'INFO' : 'DEBUG', 'log_dir' => Comm_Context::getServer('APP_LOG_DIR', '/data/www/logs'), 'web_dir' => Comm_Context::getServer('APP_WEB_DIR', '/data/www/htdocs'), 'var_dir' => Comm_Context::getServer('APP_VAR_DIR', '/data/www/var'), 'plugins' => array());
Exemplo n.º 4
0
 private function _checkRunning()
 {
     if (!Comm_Context::isCli()) {
         exit("daemon run under cli mode only!");
     }
     if (!file_exists($this->pidFile)) {
         return;
     }
     $pid = file_get_contents($this->pidFile);
     if (!file_exists("/proc/{$pid}/status")) {
         unlink($this->pidFile);
     } else {
         exit("daemon:{$this->name} already running!");
     }
 }
Exemplo n.º 5
0
 private function _doStop()
 {
     if (true !== $this->controllerObj->getLogRequest()) {
         return;
     }
     $info = array('elapse' => sprintf('%.3f', microtime(true) - SYSTEM_START_TIME), 'uri' => Comm_Context::getServer('REQUEST_URI'), 'params' => $this->controllerObj->getParams());
     Tool_Log::info('request ok, ' . Tool_Json::encode($info));
 }