Log execution time based issues for review.
This commit is contained in:
parent
a4cbd44400
commit
2ef6c3d29b
1 changed files with 29 additions and 6 deletions
|
@ -10,12 +10,14 @@ register_shutdown_function('shutdown');
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
if(in_array($_SERVER['SERVER_NAME'],array('localhost','a.io'))) {
|
if(in_array($_SERVER['SERVER_NAME'],array('localhost','a.io'))) {
|
||||||
|
$DATABASE_FILE = getcwd() . '/../conf/database.conf';
|
||||||
$CACHE_FILE = '../data/cache.txt';
|
$CACHE_FILE = '../data/cache.txt';
|
||||||
$DATA_FILE = '../data/index.txt';
|
$DATA_FILE = '../data/index.txt';
|
||||||
$LOCK_FILE = getcwd() . '/../data/whoisandrew.lock';
|
$LOCK_FILE = getcwd() . '/../data/whoisandrew.lock';
|
||||||
} else {
|
} else {
|
||||||
chdir('/home/atomaka/data');
|
chdir('/home/atomaka/data');
|
||||||
|
|
||||||
|
$DATABASE_FILE = '/home/atomaka/conf/database.conf';
|
||||||
$CACHE_FILE = 'cache.txt';
|
$CACHE_FILE = 'cache.txt';
|
||||||
$DATA_FILE = 'index.txt';
|
$DATA_FILE = 'index.txt';
|
||||||
// path changes in the shutdown() function so we need the full path
|
// path changes in the shutdown() function so we need the full path
|
||||||
|
@ -40,8 +42,6 @@ if(!file_exists($LOCK_FILE)) {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
while(true) { }
|
|
||||||
|
|
||||||
if(file_exists($CACHE_FILE)) {
|
if(file_exists($CACHE_FILE)) {
|
||||||
$cacheData = json_decode(file_get_contents($CACHE_FILE),true);
|
$cacheData = json_decode(file_get_contents($CACHE_FILE),true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -118,7 +118,8 @@ function lastfm() {
|
||||||
|
|
||||||
$cover = (is_array($latestSong->image)) ?
|
$cover = (is_array($latestSong->image)) ?
|
||||||
'img/lastfm/blank_album64.png' : (string)$latestSong->image[1];
|
'img/lastfm/blank_album64.png' : (string)$latestSong->image[1];
|
||||||
$time = (isset($latestSong->attributes()->nowplaying) && (bool)$latestSong->attributes()->nowplaying) ?
|
$time = (isset($latestSong->attributes()->nowplaying) &&
|
||||||
|
(bool)$latestSong->attributes()->nowplaying) ?
|
||||||
0 : strtotime($latestSong->date . ' UTC');
|
0 : strtotime($latestSong->date . ' UTC');
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,7 +158,8 @@ function hulu() {
|
||||||
$lastShow = $xml->channel->item[0];
|
$lastShow = $xml->channel->item[0];
|
||||||
|
|
||||||
$title = explode(' - ', $lastShow->title);
|
$title = explode(' - ', $lastShow->title);
|
||||||
preg_match('/<img src="(.*)" align="right"/',(string)$lastShow->description,$thumb);
|
preg_match('/<img src="(.*)" align="right"/',(string)$lastShow->description,
|
||||||
|
$thumb);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'series' => isset($title[2]) ? $title[2] : 'Not Available',
|
'series' => isset($title[2]) ? $title[2] : 'Not Available',
|
||||||
|
@ -250,7 +252,9 @@ function wow() {
|
||||||
$leastH = 1000;
|
$leastH = 1000;
|
||||||
foreach($bosses as $boss) {
|
foreach($bosses as $boss) {
|
||||||
if($boss->normalKills == -1) $boss->normalKills = 0;
|
if($boss->normalKills == -1) $boss->normalKills = 0;
|
||||||
if(($boss->normalKills + $boss->heroicKills) < $leastN) $leastN = $boss->normalKills + $boss->heroicKills;
|
if(($boss->normalKills + $boss->heroicKills) < $leastN) {
|
||||||
|
$leastN = $boss->normalKills + $boss->heroicKills;
|
||||||
|
}
|
||||||
if($boss->heroicKills < $leastH) $leastH = $boss->heroicKills;
|
if($boss->heroicKills < $leastH) $leastH = $boss->heroicKills;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,12 +326,31 @@ function progression_sort($a, $b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function shutdown() {
|
function shutdown() {
|
||||||
global $interruptedExecution, $LOCK_FILE, $startTime;
|
global $interruptedExecution, $startTime, $LOCK_FILE, $DATABASE_FILE;
|
||||||
|
|
||||||
|
$db_conf = json_decode(file_get_contents($DATABASE_FILE));
|
||||||
|
$db = mysqli_init();
|
||||||
|
$db->real_connect($db_conf->hostname,$db_conf->username,$db_conf->password,
|
||||||
|
$db_conf->database);
|
||||||
|
|
||||||
if(!$interruptedExecution) {
|
if(!$interruptedExecution) {
|
||||||
unlink($LOCK_FILE);
|
unlink($LOCK_FILE);
|
||||||
|
} else {
|
||||||
|
$errorTime = time();
|
||||||
|
$query = "INSERT INTO wia_log (time,type,description) VALUES($errorTime,
|
||||||
|
'warning',
|
||||||
|
'The script attempted to run while another copy was already processing')";
|
||||||
|
$db->query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
$completionTime = time() - $startTime;
|
$completionTime = time() - $startTime;
|
||||||
|
|
||||||
|
if($completionTime >= ini_get('max_execution_time')) {
|
||||||
|
$errorTime = time();
|
||||||
|
$query = "INSERT INTO wia_log (time,type,description) VALUES($errorTime,
|
||||||
|
'warning','The script reached the maximum execution time.')";
|
||||||
|
$db->query($query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in a new issue