добавлена MIT Лицензия и скорректированы некоторые файлы

This commit is contained in:
rsgrinko committed 2022-07-10 21:34:34 +03:00
1 parent 7217850315
commit 060d176805
5 files changed
+32 -9

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
Copyright (c) 2022 Roman Grinko <rsgrinko@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+2
View File
@@ -34,6 +34,7 @@
<thead>
<tr>
<th>Всего</th>
<th>Воркеров</th>
<th>Активных</th>
<th>Выполняются</th>
<th>С ошибкой</th>
@@ -43,6 +44,7 @@
<tbody>
<tr>
<td><?=$MQ->getCountTasks();?></td>
<td><?=$MQ->getCountWorkers() . ' / ' . MQ::WORKERS_LIMIT;?></td>
<td><?=$MQ->getCountTasks(['active' => 'Y']);?></td>
<td><?=$MQ->getCountTasks(['active' => 'Y', 'in_progress' => 'Y']);?></td>
<td><?=$MQ->getCountTasks(['in_progress' => 'N', 'status' => MQ::STATUS_ERROR]);?></td>
+2 -6
View File
@@ -132,12 +132,8 @@
$text = htmlspecialchars_decode($text);
$text = str_replace('\'', '\\\'', $text);
$hash = md5($text);
$res = $DB->query('SELECT * FROM bashorg WHERE hash="' . $hash . '"');
if (!$res) {
$i++;
$itemId = $DB->addItem('bashorg', ['hash' => $hash, 'text' => $text, 'etx_id' => (int)$element['id'], 'date' => $element['date'], 'rating' => $element['rating']]);
sendTelegram('<b>Добавлена цитата ID ' . $itemId . ' (' . $page . ' страница)</b>' . PHP_EOL . $text);
} else {
$res = $DB->query('SELECT * FROM bashorg WHERE hash="' . $hash . '" AND date is null');
if ($res) {
$j++;
$DB->update('bashorg', ['hash' => $hash], ['ext_id' => (int)$element['id'], 'date' => $element['date'], 'rating' => $element['rating']]);
}
+2
View File
@@ -93,6 +93,8 @@
{
if (!is_array($where)) {
return $where;
}elseif (empty($where)){
return '1';
}
$where_string = '';
foreach ($where as $where_key => $where_item) {
+14 -3
View File
@@ -59,9 +59,9 @@
const EXECUTION_TASKS_LIMIT = 100;
/**
* Лимит количества одновременно выполняемых задач
* Лимит количества запущенных воркеров
*/
const WORKERS_LIMIT = 5;
const WORKERS_LIMIT = 10;
/**
* @var DB|null $DB Объект базы
@@ -81,7 +81,7 @@
/**
* Время, после которого задача считается повисшей (5 минут)
*/
const STUCK_TIME = 60 * 5;
const STUCK_TIME = 60 * 10;
/**
* @var null $priority Приоритет задания
@@ -717,6 +717,17 @@
return (int)exec('ps -awx | grep \'threadsWorker.php\' | grep -v \'grep\' | wc -l');
}
/**
* Принудительная остановка всех запущенных воркеров
*
* @return void
*/
public function stopAllWorkers(): void
{
exec('pkill -f threadsWorker.php');
$this->DB->update(self::TABLE, [], ['active' => 'N', 'in_progress' => 'N']);
}
/**
* Проверка на максимальное количество работающих воркеров