Parser upgrade & some stats

This commit is contained in:
= 2011-04-01 16:07:09 +04:00
parent f5dba21b56
commit 6de992cfe9
3 changed files with 28 additions and 5 deletions

View File

@ -10,7 +10,7 @@ $vk = new Vkontakte();
$continue = true;
while ($continue) {
$queue = $db->getRows($db->q("SELECT * FROM beathaven.queue WHERE status=2 LIMIT 100"));
$queue = $db->getRows($db->q("SELECT * FROM beathaven.queue WHERE status=0 OR status=2 ORDER BY priority DESC, times_failed ASC LIMIT 10"));
if (!$queue || count($queue) == 0) {
$continue = false;
} else {
@ -29,7 +29,7 @@ while ($continue) {
$db->q("UPDATE beathaven.queue SET status=1 WHERE track_id=". $t['track_id']);
} else {
echo "FAILED\n\n";
$db->q("UPDATE beathaven.queue SET status=2 WHERE track_id=". $t['track_id']);
$db->q("UPDATE beathaven.queue SET status = 2, times_failed = times_failed + 1 WHERE track_id=". $t['track_id']);
}
$t2 = microtime(true);
if ($t2 - $t1 < 5) {

View File

@ -2,4 +2,5 @@
define('ROOT_DIR', getcwd());
require_once ROOT_DIR .'/autoload.php';
require_once ROOT_DIR .'/autoload.php';
Config::loadFile('app', 'config/app.ini');

View File

@ -6,10 +6,32 @@ $db = Db::getInstance();
$rows = $db->getRows($db->q("SELECT status, count(*) as cnt FROM beathaven.queue GROUP BY status"));
$info = array_fill(0, 3, array());
$info = array_fill(0, 3, 0);
foreach ($rows as $row) {
$info[$row['status']] = $row['cnt'];
}
print_r($info);
$tmp = exec("ps aux | grep parse_queue");
$running = (strpos($tmp, '/opt/local/bin/php') !== false) ? 1 : 0;
?>
<html>
<head>
<title>BeatHaven</title>
<style>
body, td {padding:0;margin:0;}
body {background-color:#112;}
.status-1 {font: 10em Georgia; color: #FFF;}
.status-02 {font: 0.8em Georgia; color: #AAA;}
.running-1 {font: 0.8em Georgia; color: #8A8;}
.running-0 {font: 0.8em Georgia; color: #A88;}
</style>
</head>
<body>
<table width="100%" height="100%"><tr><td align="center" valign="middle">
<span class="status-1"><?= $info[1] ?></span><span class="status-02"> / <?= $info[0] ?> / <?= $info[2] ?></span>
<span class="running-<?= $running ?>"><?= ($running ? 'running' : 'stopped') ?></span>
</td></tr></table>
</body>
</html>