добавлена 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

+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']);
}
/**
* Проверка на максимальное количество работающих воркеров