Finish task#3027 后台-计划任务在服务重启后可能无法读取正常的配置也有可能无法运行,cost:2 left:0
This commit is contained in:
+11
-1
@@ -128,10 +128,11 @@ class cron extends control
|
||||
/**
|
||||
* Ajax exec cron.
|
||||
*
|
||||
* @param bool $restart
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxExec()
|
||||
public function ajaxExec($restart = false)
|
||||
{
|
||||
ignore_user_abort(true);
|
||||
set_time_limit(0);
|
||||
@@ -139,6 +140,10 @@ class cron extends control
|
||||
/* Check cron turnon. */
|
||||
if(empty($this->config->global->cron)) die();
|
||||
|
||||
/* Create restart tag file. */
|
||||
$restartTag = $this->app->getCacheRoot() . 'restartcron';
|
||||
if($restart) touch($restartTag);
|
||||
|
||||
/* make cron status to running. */
|
||||
$configID = $this->cron->getConfigID();
|
||||
$configID = $this->cron->markCronStatus('running', $configID);
|
||||
@@ -158,11 +163,16 @@ class cron extends control
|
||||
if(empty($parsedCrons)) break;
|
||||
if(!$this->cron->getTurnon()) break;
|
||||
|
||||
/* Die old process when restart. */
|
||||
if(file_exists($restartTag) and !$restart) die(unlink($restartTag));
|
||||
$restart = false;
|
||||
|
||||
/* Run crons. */
|
||||
$now = new datetime('now');
|
||||
$this->common->loadConfigFromDB();
|
||||
foreach($parsedCrons as $id => $cron)
|
||||
{
|
||||
|
||||
$cronInfo = $this->cron->getById($id);
|
||||
/* Skip empty and stop cron.*/
|
||||
if(empty($cronInfo) or $cronInfo->status == 'stop') continue;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<script>
|
||||
$(function()
|
||||
{
|
||||
startCron();
|
||||
startCron(1);
|
||||
setTimeout(function(){parent.location.href = parent.location.href}, 300);
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -301,6 +301,8 @@ class mail extends control
|
||||
*/
|
||||
public function asyncSend()
|
||||
{
|
||||
/* Reload mail config. */
|
||||
$this->app->loadConfig('mail');
|
||||
$queueList = $this->mail->getQueue('wait', 'id_asc');
|
||||
$now = helper::now();
|
||||
if(isset($this->config->mail->async))$this->config->mail->async = 0;
|
||||
|
||||
+3
-2
@@ -1373,9 +1373,10 @@ function fixStyle()
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function startCron()
|
||||
function startCron(restart)
|
||||
{
|
||||
$.ajax({type:"GET", timeout:100, url:createLink('cron', 'ajaxExec')});
|
||||
if(typeof(restart) == 'undefined') restart = 0;
|
||||
$.ajax({type:"GET", timeout:100, url:createLink('cron', 'ajaxExec', 'restart=' + restart)});
|
||||
}
|
||||
|
||||
function computePasswordStrength(password)
|
||||
|
||||
Reference in New Issue
Block a user