示例#1
0
文件: main.php 项目: vincenttone/daf
 /**
  * 获取实例的方法
  * @return $this
  */
 public static function get_instance()
 {
     if (is_null(self::$_instance)) {
         $class = __CLASS__;
         self::$_instance = new $class();
     }
     return self::$_instance;
 }
示例#2
0
文件: app.php 项目: vincenttone/daf
 /**
  * @return bool
  */
 public function bootstrap()
 {
     $this->_make_app_config();
     // config manager
     $this->_autoload_register();
     // set autoloader
     Sys_Config::get_instance()->set_config_path(self::conf_path())->check_run_mode_suffix(true);
     $this->_init_log();
     // run the logger
     \Module_ModuleManager_Main::get_instance()->init_with_module_path(self::module_path());
     //init the modules manager
     return true;
 }
示例#3
0
文件: flow.php 项目: vincenttone/daf
 /**
  * @param int $task_id
  * @param int $mid
  * @param array $data
  * @return array
  */
 private function _run_module($task_id, $mid, $data)
 {
     $data = Module_ModuleManager_Main::get_instance()->run_module($task_id, $mid, $data, $this->options);
     // 数据检查
     if (!isset($data['errno'])) {
         Lib_Log::error("run module [%d] faild!. err: return data not has errno.\tdata:%s", [$mid, json_encode($data)]);
         return Lib_Helper::get_err_struct(Const_Err_Base::ERR_DATA_FORMAT, '模块[' . $mid . ']返回数据错误');
     }
     return $data;
 }
示例#4
0
 /**
  * @param string $module_indent
  * @param string $module_path
  * @return bool
  */
 private function _get_module_info_from_path($module_indent, $module_path = '')
 {
     $module_indent = strtolower($module_indent);
     if (empty($module_path)) {
         $module_path = Module_ModuleManager_Main::module_path() . '/' . $module_indent;
     }
     $entry_file = $module_path . '/' . self::ENTRY_FILE_NAME;
     if (isset($this->_all_modules[$module_indent])) {
         return $this->_all_modules[$module_indent];
     } else {
         if (file_exists($entry_file)) {
             $needed_info = self::read_comment_info_from_file($entry_file);
             $this->_all_modules[$module_indent] = $needed_info;
             $this->_all_modules[$module_indent][Model_ModulesInfo::FIELD_MODULE_VERSION] = isset($needed_info[Const_Module::META_VERSION]) ? $needed_info[Const_Module::META_VERSION] : '1.0.0';
             $_cls = self::get_module_entry_class($module_indent);
             $this->_all_modules[$module_indent][Model_ModulesInfo::FIELD_MODULE_STATUS] = self::MODULE_STATUS_UNREG;
             $this->_all_modules[$module_indent][Model_ModulesInfo::FIELD_MODULE_CLASS] = $_cls ? $_cls : 'UNKNOW';
             $this->_all_modules[$module_indent][Model_ModulesInfo::FIELD_MODULE_INDENT] = $module_indent;
             $this->_all_modules[$module_indent][Model_ModulesInfo::FIELD_MODULE_PATH] = $module_path;
             return $this->_all_modules[$module_indent];
         }
     }
     $this->_all_modules[$module_indent] = false;
     return false;
 }
示例#5
0
 /**
  * @param int $task_id
  */
 static function ratio_of_process($task_id)
 {
     $flow = Module_ControlCentre_FlowManager::current_flow()->flow;
     $main_mids = $flow[Module_FlowManager_Main::FLOW_TYPE_MAIN];
     $task_status_key = self::_current_task_status_id($task_id);
     $task_status = xcache_get($task_status_key);
     $model_module_record = new Model_TaskRunModuleRecord();
     $cmid = null;
     $pre_mid = null;
     $pre_pre_mid = null;
     while (!$task_status) {
         $current_mid_key = self::_current_mid_hook_key($task_id);
         $current_mid = xcache_get($current_mid_key);
         if ($current_mid && in_array($current_mid, $main_mids)) {
             foreach ($main_mids as $_mid) {
                 if ($_mid == $current_mid) {
                     break;
                 }
                 $pre_pre_mid = $pre_mid;
                 $pre_mid = $_mid;
             }
             $ratio = Module_ControlCentre_Counter::get_instance()->get_ratio_count($current_mid, $pre_mid);
             $record_id = Module_ModuleManager_Main::module_run_id($task_id, $current_mid);
             $ratio && $model_module_record->update_record($record_id, ['ratio' => $ratio]);
             if ($cmid != $current_mid) {
                 $cmid = $current_mid;
                 if ($pre_mid) {
                     $pre_ratio = Module_ControlCentre_Counter::get_instance()->get_ratio_count($pre_mid, $pre_pre_mid);
                     $pre_record_id = Module_ModuleManager_Main::module_run_id($task_id, $pre_mid);
                     $pre_ratio && $model_module_record->update_record($pre_record_id, ['ratio' => $pre_ratio]);
                 }
             }
         }
         $task_status = xcache_get($task_status_key);
         sleep(3);
     }
 }