Checking if Scheduled Jobs were run
This commit is contained in:
@@ -208,14 +208,18 @@ class ScheduledJob
|
||||
*/
|
||||
public function isCronConfigured()
|
||||
{
|
||||
$date = new \DateTime('-' . $this->lastCronRunTime, new \DateTimeZone("UTC"));
|
||||
$nowDate = new \DateTime('now', new \DateTimeZone("UTC"));
|
||||
$startDate = new \DateTime('-' . $this->lastCronRunTime, new \DateTimeZone("UTC"));
|
||||
|
||||
$query = "
|
||||
SELECT COUNT(id) as count FROM job
|
||||
SELECT job.id FROM scheduled_job
|
||||
LEFT JOIN job ON job.scheduled_job_id = scheduled_job.id AND job.deleted = 0
|
||||
WHERE
|
||||
deleted = 0
|
||||
AND `status` IN ('Success', 'Failed')
|
||||
AND execute_time > '" . $date->format('Y-m-d H:i:s') . "'
|
||||
scheduled_job.job = 'Dummy'
|
||||
AND scheduled_job.deleted = 0
|
||||
AND job.execute_time BETWEEN '". $startDate->format('Y-m-d H:i:s') ."' AND '". $nowDate->format('Y-m-d H:i:s') ."'
|
||||
AND (job.status IN ('Success', 'Failed') OR (job.status = 'Pending' AND job.execute_time >= '". $nowDate->modify('-1 hour')->format('Y-m-d H:i:s') ."') )
|
||||
ORDER BY job.execute_time DESC
|
||||
";
|
||||
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
@@ -223,7 +227,8 @@ class ScheduledJob
|
||||
$sth->execute();
|
||||
|
||||
$row = $sth->fetch(\PDO::FETCH_ASSOC);
|
||||
if (isset($row['count']) && $row['count'] >= 1) {
|
||||
|
||||
if (!empty($row['id'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Jobs;
|
||||
|
||||
class Dummy extends \Espo\Core\Jobs\Base
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -72,5 +72,11 @@
|
||||
"Cleanup": "1 1 * * 0",
|
||||
"AuthTokenControl": "*/6 * * * *",
|
||||
"SendEmailNotifications": "*/2 * * * *"
|
||||
},
|
||||
"jobs": {
|
||||
"Dummy": {
|
||||
"isSystem": true,
|
||||
"scheduling": "1 */12 * * *"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,10 +233,10 @@ class Installer
|
||||
$result = false;
|
||||
|
||||
try {
|
||||
$result = $this->app->getContainer()->get('schema')->rebuild();
|
||||
$result = $this->app->getContainer()->get('dataManager')->rebuild();
|
||||
} catch (\Exception $e) {
|
||||
$this->auth();
|
||||
$result = $this->app->getContainer()->get('schema')->rebuild();
|
||||
$result = $this->app->getContainer()->get('dataManager')->rebuild();
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -451,6 +451,4 @@ class Installer
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -28,5 +28,5 @@
|
||||
************************************************************************/
|
||||
|
||||
return array(
|
||||
|
||||
"INSERT INTO `job` (`id`, `name`, `deleted`, `status`, `execute_time`, `service_name`, `method`, `data`, `attempts`, `failed_attempts`, `created_at`, `modified_at`, `scheduled_job_id`, `target_id`, `target_type`) VALUES ('". uniqid() ."', 'Dummy', '0', 'Pending', '" . gmdate('Y-m-d H:i:s') . "', NULL, 'Dummy', NULL, '3', NULL, '" . gmdate('Y-m-d H:i:s') . "', '" . gmdate('Y-m-d H:i:s') . "', (SELECT id FROM scheduled_job WHERE deleted = 0 AND job = 'Dummy'), NULL, NULL);"
|
||||
);
|
||||
Reference in New Issue
Block a user