Don't create lock files if the process is called from the poller via the worker

This commit is contained in:
Michael Vogel 2016-03-08 00:20:06 +01:00
parent fa652ad1bc
commit ec9c9f0be7
8 changed files with 141 additions and 113 deletions

View file

@ -40,6 +40,8 @@ function cron_run(&$argv, &$argc){
load_config('config');
load_config('system');
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
$maxsysload = intval(get_config('system','maxloadavg'));
if($maxsysload < 1)
$maxsysload = 50;
@ -47,21 +49,7 @@ function cron_run(&$argv, &$argc){
$load = current_load();
if($load) {
if(intval($load) > $maxsysload) {
logger('system: load ' . $load . ' too high. cron deferred to next scheduled run.');
return;
}
}
$last = get_config('system','last_cron');
$poll_interval = intval(get_config('system','cron_interval'));
if(! $poll_interval)
$poll_interval = 10;
if($last) {
$next = $last + ($poll_interval * 60);
if($next > time()) {
logger('cron intervall not reached');
logger('system: load '.$load.' too high. cron deferred to next scheduled run.');
return;
}
}
@ -80,8 +68,21 @@ function cron_run(&$argv, &$argc){
exit;
}
}
}
$last = get_config('system','last_cron');
$poll_interval = intval(get_config('system','cron_interval'));
if(! $poll_interval)
$poll_interval = 10;
if($last) {
$next = $last + ($poll_interval * 60);
if($next > time()) {
logger('cron intervall not reached');
return;
}
}
$a->set_baseurl(get_config('system','url'));

View file

@ -24,6 +24,8 @@ function cronhooks_run(&$argv, &$argc){
load_config('config');
load_config('system');
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
$maxsysload = intval(get_config('system','maxloadavg'));
if($maxsysload < 1)
$maxsysload = 50;
@ -36,20 +38,6 @@ function cronhooks_run(&$argv, &$argc){
}
}
$last = get_config('system','last_cronhook');
$poll_interval = intval(get_config('system','cronhook_interval'));
if(! $poll_interval)
$poll_interval = 9;
if($last) {
$next = $last + ($poll_interval * 60);
if($next > time()) {
logger('cronhook intervall not reached');
return;
}
}
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'cronhooks');
@ -64,6 +52,21 @@ function cronhooks_run(&$argv, &$argc){
exit;
}
}
}
$last = get_config('system','last_cronhook');
$poll_interval = intval(get_config('system','cronhook_interval'));
if(! $poll_interval)
$poll_interval = 9;
if($last) {
$next = $last + ($poll_interval * 60);
if($next > time()) {
logger('cronhook intervall not reached');
return;
}
}
$a->set_baseurl(get_config('system','url'));

View file

@ -25,6 +25,8 @@ function discover_poco_run(&$argv, &$argc){
load_config('config');
load_config('system');
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
$maxsysload = intval(get_config('system','maxloadavg'));
if($maxsysload < 1)
$maxsysload = 50;
@ -32,10 +34,11 @@ function discover_poco_run(&$argv, &$argc){
$load = current_load();
if($load) {
if(intval($load) > $maxsysload) {
logger('system: load ' . $load . ' too high. discover_poco deferred to next scheduled run.');
logger('system: load '.$load.' too high. discover_poco deferred to next scheduled run.');
return;
}
}
}
if(($argc > 2) && ($argv[1] == "dirsearch")) {
$search = urldecode($argv[2]);
@ -50,6 +53,8 @@ function discover_poco_run(&$argv, &$argc){
} else
die("Unknown or missing parameter ".$argv[1]."\n");
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'discover_poco'.$mode.urlencode($search));
@ -65,6 +70,7 @@ function discover_poco_run(&$argv, &$argc){
exit;
}
}
}
$a->set_baseurl(get_config('system','url'));

View file

@ -60,6 +60,8 @@ function onepoll_run(&$argv, &$argc){
return;
}
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'onepoll'.$contact_id);
@ -72,6 +74,7 @@ function onepoll_run(&$argv, &$argc){
exit;
}
}
}
$d = datetime_convert();

View file

@ -954,16 +954,21 @@ function ostatus_completion($conversation_url, $uid, $item = array(), $self = ""
if (isset($single_conv->actor->url))
$actor = $single_conv->actor->url;
$contact = q("SELECT `id`, `rel` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` != '%s'",
$contact = q("SELECT `id`, `rel`, `network` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` != '%s'",
$uid, normalise_link($actor), NETWORK_STATUSNET);
if (count($contact)) {
if (!$contact)
$contact = q("SELECT `id`, `rel`, `network` FROM `contact` WHERE `uid` = %d AND `alias` IN ('%s', '%s') AND `network` != '%s'",
$uid, $actor, normalise_link($actor), NETWORK_STATUSNET);
if ($contact) {
logger("Found contact for url ".$actor, LOGGER_DEBUG);
$contact_id = $contact[0]["id"];
$network = $contact[0]["network"];
$not_following = !in_array($contact[0]["rel"], array(CONTACT_IS_SHARING, CONTACT_IS_FRIEND));
} else {
logger("No contact found for url ".$actor, LOGGER_DEBUG);
logger("No contact found for user ".$uid." and url ".$actor, LOGGER_DEBUG);
// Adding a global contact
/// @TODO Use this data for the post
@ -972,18 +977,19 @@ function ostatus_completion($conversation_url, $uid, $item = array(), $self = ""
logger("Global contact ".$global_contact_id." found for url ".$actor, LOGGER_DEBUG);
$contact_id = $parent["contact-id"];
$network = NETWORK_OSTATUS;
$not_following = true;
}
// Do we only want to import threads that were started by our contacts?
if ($not_following AND $new_parent AND get_config('system','ostatus_full_threads')) {
logger("Don't import uri ".$first_id." because we don't follow the person ".$actor, LOGGER_DEBUG);
logger("Don't import uri ".$first_id." because user ".$uid." doesn't follow the person ".$actor, LOGGER_DEBUG);
continue;
}
$arr = array();
$arr["network"] = NETWORK_OSTATUS;
$arr["network"] = $network;
$arr["uri"] = $single_conv->id;
$arr["plink"] = $plink;
$arr["uid"] = $uid;

View file

@ -79,6 +79,8 @@ function pubsubpublish_run(&$argv, &$argc){
load_config('config');
load_config('system');
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'pubsubpublish');
@ -93,6 +95,7 @@ function pubsubpublish_run(&$argv, &$argc){
return;
}
}
}
$a->set_baseurl(get_config('system','url'));

View file

@ -28,6 +28,8 @@ function queue_run(&$argv, &$argc){
load_config('config');
load_config('system');
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'queue');
@ -42,6 +44,7 @@ function queue_run(&$argv, &$argc){
return;
}
}
}
$a->set_baseurl(get_config('system','url'));

View file

@ -37,6 +37,8 @@ function update_gcontact_run(&$argv, &$argc){
return;
}
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'update_gcontact'.$contact_id);
@ -49,6 +51,7 @@ function update_gcontact_run(&$argv, &$argc){
exit;
}
}
}
$r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id));