From 6de992cfe9af8642cc6da30f0473808bf69edea5 Mon Sep 17 00:00:00 2001 From: = <=> Date: Fri, 1 Apr 2011 16:07:09 +0400 Subject: [PATCH] Parser upgrade & some stats --- php/bin/parse_queue.php | 4 ++-- php/common.php | 3 ++- php/index.php | 26 ++++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/php/bin/parse_queue.php b/php/bin/parse_queue.php index cde8395..34189ca 100755 --- a/php/bin/parse_queue.php +++ b/php/bin/parse_queue.php @@ -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) { diff --git a/php/common.php b/php/common.php index e4fb7b1..403f4fb 100644 --- a/php/common.php +++ b/php/common.php @@ -2,4 +2,5 @@ define('ROOT_DIR', getcwd()); -require_once ROOT_DIR .'/autoload.php'; \ No newline at end of file +require_once ROOT_DIR .'/autoload.php'; +Config::loadFile('app', 'config/app.ini'); diff --git a/php/index.php b/php/index.php index ad30afc..9213062 100644 --- a/php/index.php +++ b/php/index.php @@ -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; + +?> + +
++= $info[1] ?> / = $info[0] ?> / = $info[2] ?> += ($running ? 'running' : 'stopped') ?> + |