Added functionality to kill processes
This commit is contained in:
parent
e42939a2e3
commit
ced417da6c
|
@ -24,6 +24,7 @@ namespace Friendica\Worker;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Tag;
|
use Friendica\Model\Tag;
|
||||||
|
|
||||||
|
@ -54,6 +55,10 @@ class Cron
|
||||||
copy($basepath . '/.htaccess-dist', $basepath . '/.htaccess');
|
copy($basepath . '/.htaccess-dist', $basepath . '/.htaccess');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DI::config()->get('system', 'delete_sleeping_processes')) {
|
||||||
|
self::deleteSleepingProcesses();
|
||||||
|
}
|
||||||
|
|
||||||
// Fork the cron jobs in separate parts to avoid problems when one of them is crashing
|
// Fork the cron jobs in separate parts to avoid problems when one of them is crashing
|
||||||
Hook::fork(PRIORITY_MEDIUM, 'cron');
|
Hook::fork(PRIORITY_MEDIUM, 'cron');
|
||||||
|
|
||||||
|
@ -137,4 +142,26 @@ class Cron
|
||||||
|
|
||||||
DI::config()->set('system', 'last_cron', time());
|
DI::config()->set('system', 'last_cron', time());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kill sleeping database processes
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private static function deleteSleepingProcesses()
|
||||||
|
{
|
||||||
|
Logger::info('Looking for sleeping processes');
|
||||||
|
|
||||||
|
$processes = DBA::p("SHOW FULL PROCESSLIST");
|
||||||
|
while ($process = DBA::fetch($processes)) {
|
||||||
|
// To-Do: Auf Datenbank abgrenzen
|
||||||
|
if (($process['Command'] != 'Sleep') || ($process['Time'] < 60) || ($process['db'] != DBA::databaseName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBA::e("KILL ?", $process['Id']);
|
||||||
|
Logger::notice('Killed sleeping process', ['id' => $process['Id']]);
|
||||||
|
}
|
||||||
|
DBA::close($processes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue