mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-04-28 23:19:21 +03:00
fix cron and logger
This commit is contained in:
parent
f7e072ac3c
commit
20ab59b570
|
@ -113,6 +113,7 @@ $config['sys']['logs']['sql_query'] = false; // логирова
|
|||
$config['sys']['logs']['sql_query_file'] = 'sql_query.log'; // файл лога SQL запросов
|
||||
$config['sys']['logs']['sql_error'] = true; // логировать или нет ошибки SQl
|
||||
$config['sys']['logs']['sql_error_file'] = 'sql_error.log'; // файл лога ошибок SQL
|
||||
$config['sys']['logs']['cron'] = true; // логировать или нет cron скрипты
|
||||
$config['sys']['logs']['cron_file'] = 'cron.log'; // файл лога запуска крон-процессов
|
||||
$config['sys']['logs']['profiler'] = false; // логировать или нет профилирование процессов
|
||||
$config['sys']['logs']['profiler_file'] = 'profiler.log'; // файл лога профилирования процессов
|
||||
|
|
|
@ -36,9 +36,10 @@ class Cron extends Object {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $sProcessName='Cron';
|
||||
protected $sProcessName;
|
||||
|
||||
public function __construct($sLockFile=null) {
|
||||
$this->sProcessName=get_class($this);
|
||||
$this->oEngine=Engine::getInstance();
|
||||
/**
|
||||
* Инициализируем ядро
|
||||
|
@ -63,8 +64,10 @@ class Cron extends Object {
|
|||
* @return
|
||||
*/
|
||||
public function Log($sMsg) {
|
||||
$sMsg=$this->sProcessName.': '.$sMsg;
|
||||
$this->oEngine->Logger_Notice($sMsg);
|
||||
if (Config::Get('sys.logs.cron')) {
|
||||
$sMsg=$this->sProcessName.': '.$sMsg;
|
||||
$this->oEngine->Logger_Notice($sMsg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,5 +132,9 @@ class Cron extends Object {
|
|||
public function Client(){
|
||||
throw new Exception('Call undefined client function');
|
||||
}
|
||||
|
||||
public function __call($sName,$aArgs) {
|
||||
return $this->oEngine->_CallModule($sName,$aArgs);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -63,6 +63,12 @@ class ModuleLogger extends Module {
|
|||
* @var int
|
||||
*/
|
||||
protected $iSizeForRotate=1000000;
|
||||
/**
|
||||
* Случайное число
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
protected $iRandom;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -72,6 +78,7 @@ class ModuleLogger extends Module {
|
|||
public function Init() {
|
||||
$this->sPathLogs=Config::Get('path.root.server').'/logs/';
|
||||
$this->SetFileName(Config::Get('sys.logs.file'));
|
||||
$this->iRandom=rand(1000,9999);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -199,6 +206,7 @@ class ModuleLogger extends Module {
|
|||
*/
|
||||
$msgOut ='['.date("Y-m-d H:i:s").']';
|
||||
$msgOut.='['.getmypid().']';
|
||||
$msgOut.='['.$this->iRandom.']';
|
||||
$msgOut.='['.$this->logLevel[$key].']';
|
||||
$msgOut.='['.$msg.']';
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
define('SYS_HACKER_CONSOLE',false);
|
||||
|
||||
$sDirRoot=dirname(dirname(dirname(__FILE__)));
|
||||
set_include_path(get_include_path().PATH_SEPARATOR.$sDirRoot);
|
||||
|
@ -24,15 +23,14 @@ require_once($sDirRoot."/config/loader.php");
|
|||
require_once($sDirRoot."/engine/classes/Cron.class.php");
|
||||
|
||||
class NotifyCron extends Cron {
|
||||
protected $sProcessName='NotifyCron';
|
||||
/**
|
||||
* Выбираем пул заданий и рассылаем по ним e-mail
|
||||
*/
|
||||
public function Client() {
|
||||
$aNotifyTasks = $this->oEngine->Notify_GetTasksDelayed(Config::Get('module.notify.per_process'));
|
||||
$aNotifyTasks = $this->Notify_GetTasksDelayed(Config::Get('module.notify.per_process'));
|
||||
|
||||
if(empty($aNotifyTasks)) {
|
||||
print PHP_EOL."No tasks are found.";
|
||||
$this->Log("No tasks are found.");
|
||||
return;
|
||||
}
|
||||
/**
|
||||
|
@ -40,14 +38,14 @@ class NotifyCron extends Cron {
|
|||
*/
|
||||
$aArrayId=array();
|
||||
foreach ($aNotifyTasks as $oTask) {
|
||||
$this->oEngine->Notify_SendTask($oTask);
|
||||
$this->Notify_SendTask($oTask);
|
||||
$aArrayId[]=$oTask->getTaskId();
|
||||
}
|
||||
print PHP_EOL."Send notify: ".count($aArrayId);
|
||||
$this->Log("Send notify: ".count($aArrayId));
|
||||
/**
|
||||
* Удаляем отработанные задания
|
||||
*/
|
||||
$this->oEngine->Notify_DeleteTaskByArrayId($aArrayId);
|
||||
$this->Notify_DeleteTaskByArrayId($aArrayId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
define('SYS_HACKER_CONSOLE',false);
|
||||
|
||||
$sDirRoot=dirname(dirname(dirname(__FILE__)));
|
||||
set_include_path(get_include_path().PATH_SEPARATOR.$sDirRoot);
|
||||
|
@ -24,19 +23,17 @@ require_once($sDirRoot."/config/loader.php");
|
|||
require_once($sDirRoot."/engine/classes/Cron.class.php");
|
||||
|
||||
class TemplateCacheCleanCron extends Cron {
|
||||
protected $sProcessName='TemplateCacheCleanCron';
|
||||
/**
|
||||
* Находим все кеш-файлы js и css и удаляем их с сервера
|
||||
*/
|
||||
public function Client() {
|
||||
$sDir = Config::Get('path.smarty.cache');
|
||||
/**
|
||||
* Выбираем все файлы кеша
|
||||
*/
|
||||
$aFiles = glob($sDir. DIRECTORY_SEPARATOR ."*.{css,js}", GLOB_BRACE);
|
||||
$aFiles = glob(Config::Get('path.smarty.cache'). DIRECTORY_SEPARATOR ."*\*.{css,js}", GLOB_BRACE);
|
||||
if (!$aFiles) $aFiles=array();
|
||||
|
||||
print PHP_EOL."Cache files count: ".count($aFiles);
|
||||
$this->Log("Cache files count: ".count($aFiles));
|
||||
|
||||
foreach ($aFiles as $sFilePath) {
|
||||
@unlink($sFilePath);
|
||||
|
|
Loading…
Reference in a new issue