[*] MQ добавил поиск и исправление зависших заданий

This commit is contained in:
rsgrinko committed 2022-07-08 15:35:00 +03:00
1 parent 645b5c3a00
commit 1add64675b
3 files changed
+22 -3

No files matched your search

+12 -1
View File
@@ -3,6 +3,10 @@
use Core\Models\{User, Roles}; use Core\Models\{User, Roles};
require_once __DIR__ . '/inc/header.php'; require_once __DIR__ . '/inc/header.php';
if (isset($_REQUEST['execute']) && $_REQUEST['execute'] == 'Y') {
$_SESSION['phpcmd_query'] = $_REQUEST['query'];
}
?> ?>
<div class="pageheader"> <div class="pageheader">
<div class="media"> <div class="media">
@@ -51,7 +55,14 @@
<div class="mb-3"> <div class="mb-3">
<label for="query" class="form-label">Введите PHP код для выполнения</label> <label for="query" class="form-label">Введите PHP код для выполнения</label>
<textarea class="form-control" rows="8" id="query" <textarea class="form-control" rows="8" id="query"
name="query"><?php echo isset($_REQUEST['query']) ? $_REQUEST['query'] : ''; ?></textarea> name="query"><?php
if (isset($_REQUEST['query']) && !empty($_REQUEST['query'])) {
echo $_REQUEST['query'];
} elseif (isset($_SESSION['phpcmd_query']) && !empty($_SESSION['phpcmd_query'])) {
echo $_SESSION['phpcmd_query'];
}
?></textarea>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<input id="use_pre" type="checkbox" name="use_pre" value="Y" <?php if (isset($_REQUEST['use_pre']) and $_REQUEST['use_pre'] <input id="use_pre" type="checkbox" name="use_pre" value="Y" <?php if (isset($_REQUEST['use_pre']) and $_REQUEST['use_pre']
+1
View File
@@ -178,6 +178,7 @@
*/ */
public function query(string $sql, bool $returnObject = false) public function query(string $sql, bool $returnObject = false)
{ {
sendTelegram($sql);
$startTime = microtime(true); $startTime = microtime(true);
self::$quantity++; self::$quantity++;
try { try {
+9 -2
View File
@@ -142,7 +142,7 @@
*/ */
public static function test2(...$params): string public static function test2(...$params): string
{ {
sleep(rand(10, 30)); //sleep(rand(10, 30));
$result = rand(0, 100); $result = rand(0, 100);
if (($result % 2) == 0) { if (($result % 2) == 0) {
throw new CoreException('Сервер обмена временно недоступен'); throw new CoreException('Сервер обмена временно недоступен');
@@ -719,7 +719,14 @@
} }
} }
$this->DB->query('UPDATE ' . self::TABLE . ' SET active="' . self::VALUE_N . '", in_progress="' . self::VALUE_N . '" WHERE id in(' . implode(',', $arStuckTasks) . ')'); if (!empty($arStuckTasks)) {
$this->DB->query(
'UPDATE ' . self::TABLE . ' SET active="' . self::VALUE_N . '", in_progress="' . self::VALUE_N . '" WHERE id in(' . implode(
',',
$arStuckTasks
) . ')'
);
}
Log::logToFile( Log::logToFile(
'Задания были возвращены в работу', 'Задания были возвращены в работу',
self::LOG_FILE, self::LOG_FILE,