Only check for stale processes every 5 minutes
This commit is contained in:
parent
4fdaca861b
commit
8be52424f5
11
boot.php
11
boot.php
|
@ -22,6 +22,7 @@ require_once(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'a
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
use Friendica\Util\Lock;
|
||||||
|
|
||||||
require_once 'include/config.php';
|
require_once 'include/config.php';
|
||||||
require_once 'include/network.php';
|
require_once 'include/network.php';
|
||||||
|
@ -1100,8 +1101,16 @@ function proc_run($cmd) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there is a lock then we don't have to check for too much worker
|
||||||
|
if (!Lock::set('poller_worker', 0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If there are already enough workers running, don't fork another one
|
// If there are already enough workers running, don't fork another one
|
||||||
if (poller_too_much_workers()) {
|
$quit = poller_too_much_workers();
|
||||||
|
Lock::remove('poller_worker');
|
||||||
|
|
||||||
|
if ($quit) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,13 +47,12 @@ function poller_run($argv, $argc){
|
||||||
// We now start the process. This is done after the load check since this could increase the load.
|
// We now start the process. This is done after the load check since this could increase the load.
|
||||||
$a->start_process();
|
$a->start_process();
|
||||||
|
|
||||||
// At first we check the number of workers and quit if there are too much of them
|
// Kill stale processes every 5 minutes
|
||||||
// This is done at the top to avoid that too much code is executed without a need to do so,
|
$last_cleanup = Config::get('system', 'poller_last_cleaned', 0);
|
||||||
// since the poller mostly quits here.
|
if (time() > ($last_cleanup + 300)) {
|
||||||
if (poller_too_much_workers()) {
|
logger('CLEAN: '.time().' > '.($last_cleanup + 300).' - '.$last_cleanup);
|
||||||
|
Config::set('system', 'poller_last_cleaned', time());
|
||||||
poller_kill_stale_workers();
|
poller_kill_stale_workers();
|
||||||
logger('Pre check: Active worker limit reached, quitting.', LOGGER_DEBUG);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we have too few memory?
|
// Do we have too few memory?
|
||||||
|
|
|
@ -19,7 +19,7 @@ function pubsubpublish_run(&$argv, &$argc){
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG);
|
logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG);
|
||||||
proc_run(array('priority' => PRIORITY_HIGH, 'created' => $a->queue['created'], 'dont_fork' => true),
|
proc_run(array('priority' => PRIORITY_HIGH, 'created' => $a->queue['created'], 'dont_fork' => true),
|
||||||
'include/pubsubpublish.php', $rr["id"]);
|
'include/pubsubpublish.php', (int)$rr["id"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue