Performance stuff: Caching for getsiteinfo function, check before running onepoll.php
This commit is contained in:
parent
2ac42036fb
commit
4fb059095f
3 changed files with 26 additions and 13 deletions
|
@ -948,7 +948,12 @@ function add_page_info_data($data) {
|
||||||
function add_page_info($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") {
|
function add_page_info($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") {
|
||||||
require_once("mod/parse_url.php");
|
require_once("mod/parse_url.php");
|
||||||
|
|
||||||
$data = parseurl_getsiteinfo($url, true);
|
$data = Cache::get("parse_url:".$url);
|
||||||
|
if (is_null($data)){
|
||||||
|
$data = parseurl_getsiteinfo($url, true);
|
||||||
|
Cache::set("parse_url:".$url,serialize($data));
|
||||||
|
} else
|
||||||
|
$data = unserialize($data);
|
||||||
|
|
||||||
if ($photo != "")
|
if ($photo != "")
|
||||||
$data["images"][0]["src"] = $photo;
|
$data["images"][0]["src"] = $photo;
|
||||||
|
|
|
@ -57,17 +57,19 @@ function onepoll_run(&$argv, &$argc){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test
|
|
||||||
$lockpath = get_lockpath();
|
$lockpath = get_lockpath();
|
||||||
if ($lockpath != '') {
|
if ($lockpath != '') {
|
||||||
$pidfile = new pidfile($lockpath, 'onepoll'.$contact_id);
|
$pidfile = new pidfile($lockpath, 'onepoll'.$contact_id);
|
||||||
if($pidfile->is_already_running()) {
|
if ($pidfile->is_already_running()) {
|
||||||
logger("onepoll: Already running for contact ".$contact_id);
|
logger("onepoll: Already running for contact ".$contact_id);
|
||||||
|
if ($pidfile->running_time() > 9*60) {
|
||||||
|
$pidfile->kill();
|
||||||
|
logger("killed stale process");
|
||||||
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$d = datetime_convert();
|
$d = datetime_convert();
|
||||||
|
|
||||||
// Only poll from those with suitable relationships,
|
// Only poll from those with suitable relationships,
|
||||||
|
|
|
@ -285,7 +285,13 @@ function poller_run(&$argv, &$argc){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_run('php','include/onepoll.php',$contact['id']);
|
// Don't run onepoll.php if the contact isn't pollable
|
||||||
|
// This check also is inside the onepoll.php - but this will reduce the load
|
||||||
|
if (in_array($contact["rel"], array(CONTACT_IS_SHARING, CONTACT_IS_FRIEND)) AND ($contact["poll"] != "")
|
||||||
|
AND !in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_FACEBOOK, NETWORK_PUMPIO, NETWORK_TWITTER, NETWORK_APPNET))
|
||||||
|
AND !$contact["self"] AND !$contact["blocked"] AND !$contact["readonly"] AND !$contact["archive"])
|
||||||
|
proc_run('php','include/onepoll.php',$contact['id']);
|
||||||
|
|
||||||
if($interval)
|
if($interval)
|
||||||
@time_sleep_until(microtime(true) + (float) $interval);
|
@time_sleep_until(microtime(true) + (float) $interval);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue