예제 #1
0
 public function __construct()
 {
     parent::__construct("public.notificacoes");
     $configs = new LoadConfig('central_notificacoes');
     $this->tempoUpdate = (int) $configs->item('tempo_update');
     $this->consultas = $configs->item('id');
     $this->tempoNotif = $configs->item('tempo_notif');
     $this->parametros = $this->ultimosValores = array();
     $this->setAutoCriarTabelas(TRUE)->mapearVar('consulta_id', PDO::PARAM_STR, 250)->mapearVar('ult_valor', PDO::PARAM_INT)->mapearVar('parametros', PDO::PARAM_STR, 500);
 }
 /**
  * 从配置文件载入配置
  */
 protected static function load_config()
 {
     if (is_dir(self::$config_file)) {
         self::$ori_config = self::load_by_path(self::$config_file);
     } elseif (is_file(self::$config_file)) {
         self::$ori_config = (include self::$config_file);
     }
 }
예제 #3
0
 protected function _getMessage($params)
 {
     $class = $this->_getTraces(10)[9]["class"];
     $errorCode = LoadConfig::stGetConfigVarClass("errorCodeMessage", $class);
     if (isset($errorCode[$params["errorCode"]])) {
         return $errorCode[$params["errorCode"]];
     }
     return null;
 }
예제 #4
0
 function delcrontab_cron($params)
 {
     $task = $params["get"]["taskid"];
     if (!is_string($task)) {
         return $this->output("参数有误", false);
     }
     LoadConfig::del_config($task);
     LoadConfig::reload_config();
     return $this->output("ok");
 }
 static function stGetFieldsConfig()
 {
     static $stCache = array();
     $class = get_called_class();
     if (isset($stCache[$class])) {
         return $stCache[$class];
     }
     $ret = array();
     do {
         $objField = LoadConfig::stGetConfigVarClass("objField", $class);
         if ($objField !== false) {
             $ret = array_merge($objField, $ret);
         }
     } while (($class = get_parent_class($class)) != false);
     $stCache[$class] = $ret;
     return $ret;
 }
예제 #6
0
 /**
  * Obtiene el config de una clase
  */
 static function stGetConfigVarClass($var, $class = "")
 {
     static $stCache = array();
     $class = $class != "" ? $class : static::stGetPreviousCalledClass();
     // Quiza ya haya sido cargado
     if (isset($stCache[$class][$var])) {
         return $stCache[$class][$var];
     }
     $path = LoadConfig::_stGetConfigPath($class);
     if ($path === false) {
         return false;
     }
     $config = LoadConfig::_stRequireConfig($path);
     if (isset($config[$class][$var])) {
         $stCache[$class][$var] = $config[$class][$var];
         return $config[$class][$var];
     }
     return false;
 }
예제 #7
0
 /**
  * 注册信号
  */
 private static function register_signal()
 {
     swoole_process::signal(SIGTERM, function ($signo) {
         if (!empty(Main::$http_server)) {
             swoole_process::kill(Main::$http_server->pid, SIGKILL);
         }
         self::exit2p("收到退出信号,退出主进程");
     });
     swoole_process::signal(SIGCHLD, function ($signo) {
         while (($pid = pcntl_wait($status, WNOHANG)) > 0) {
             $task = self::$task_list[$pid];
             $end = microtime(true);
             $start = $task["start"];
             $id = $task["id"];
             Main::log_write("{$id} [Runtime:" . sprintf("%0.6f", $end - $start) . "]");
             unset(self::$task_list[$pid]);
             if (isset(self::$unique_list[$id]) && self::$unique_list[$id] > 0) {
                 self::$unique_list[$id]--;
             }
         }
     });
     swoole_process::signal(SIGUSR1, function ($signo) {
         LoadConfig::reload_config();
     });
 }
 static function stRelativizeUrl($URL)
 {
     $urlBase = LoadConfig::stGetConfigClass()["urlBase"];
     return preg_replace("%{$urlBase}%", "", $URL);
 }
 protected function __construct($params = array())
 {
     $params = array_merge(array("link" => $this->_connect(LoadConfig::stGetConfigClass())), $params);
     parent::__construct($params);
 }