diff --git a/framework/base/router.class.php b/framework/base/router.class.php index ff139e5f09..0af69307d2 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -2063,9 +2063,13 @@ class baseRouter } /* 合并Hook文件。Cycle the hook methods and merge hook codes. */ - $hookedMethods = array_keys($hookCodes); + $hookedMethods = array_keys($hookCodes); $mainTargetCodes = file($mainTargetFile); $mergedTargetCodes = file($tmpTargetFile); + + /* 如果已经合并,不需要再合并了。 If merged by other thread, return directly. */ + if(!$mergedTargetCodes) return; + foreach($hookedMethods as $method) { /* 通过反射获得hook脚本对应的方法所在的文件和起止行数。Reflection the hooked method to get it's defined position. */ diff --git a/module/cron/control.php b/module/cron/control.php index fef3613ab9..bb9bb3f3b3 100644 --- a/module/cron/control.php +++ b/module/cron/control.php @@ -137,6 +137,7 @@ class cron extends control { if(empty($this->config->global->cron)) return; + /* Run as daemon. */ ignore_user_abort(true); set_time_limit(0); session_write_close(); @@ -148,10 +149,10 @@ class cron extends control while(true) { + /* Only one scheduler and max 4 consumers. */ $roles = $this->applyExecRoles($execId); if(empty($roles)) { - $this->cron->logCron('exit'); ignore_user_abort(false); return; } @@ -226,7 +227,7 @@ class cron extends control /** * 检查该execId是否可以进行调度(最近1分钟没有其他进程在调度). - * Check the execId can schedule(No other execId scheduled 10 minutes ago). + * Check the execId can schedule(No other execId scheduled 1 minutes ago). * * @param int $execId * @access protected @@ -243,7 +244,7 @@ class cron extends control /** * 检查该execId是否可以执行任务(最多允许1个调度进程,4个执行进程). - * Check the execId can exec(1 scheduler, 4 consumer). + * Check the execId can exec(1 scheduler, 4 consumers). * * @param int $execId * @access protected @@ -276,7 +277,6 @@ class cron extends control $this->dao->delete()->from(TABLE_CONFIG)->where('id')->eq($setting->id)->exec(); } } - } if(in_array($scheduler['execId'], array(0, $execId)) || $scheduler['lastTime'] < $expirDate) $roles[] = 'scheduler';