[xiph-commits] r14668 - in branches/dir.xiph.org: . cgi-bin cronjobs inc
balbinus at svn.xiph.org
balbinus at svn.xiph.org
Mon Apr 7 12:47:05 PDT 2008
Author: balbinus
Date: 2008-04-07 12:47:05 -0700 (Mon, 07 Apr 2008)
New Revision: 14668
Modified:
branches/dir.xiph.org/by_format.php
branches/dir.xiph.org/by_genre.php
branches/dir.xiph.org/cgi-bin/yp.php
branches/dir.xiph.org/cronjobs/check_servers.php
branches/dir.xiph.org/cronjobs/generate_tagcloud.php
branches/dir.xiph.org/cronjobs/generate_top.php
branches/dir.xiph.org/cronjobs/update_stats.php
branches/dir.xiph.org/inc/inc.db.php
branches/dir.xiph.org/inc/prepend.php
branches/dir.xiph.org/index.php
branches/dir.xiph.org/listen.php
branches/dir.xiph.org/search.php
Log:
More setting up the production environment: cleanup on Memcache keys, removed debug in production, plus getting the cronjobs to work in production, separately from other environments.
Modified: branches/dir.xiph.org/by_format.php
===================================================================
--- branches/dir.xiph.org/by_format.php 2008-04-07 19:22:21 UTC (rev 14667)
+++ branches/dir.xiph.org/by_format.php 2008-04-07 19:47:05 UTC (rev 14668)
@@ -15,7 +15,7 @@
$memcache = DirXiphOrgMCC::getInstance();
// Get the data from the Memcache server
- if (($results = $memcache->get('prod_search_format_'.$search_string_hash)) === false)
+ if (($results = $memcache->get(ENVIRONMENT.'_search_format_'.$search_string_hash)) === false)
{
// Database connection
$db = DirXiphOrgDBC::getInstance();
@@ -40,7 +40,7 @@
}
// Cache the resultset
- $memcache->set('prod_search_format_'.$search_string_hash, $results, false, 60);
+ $memcache->set(ENVIRONMENT.'_search_format_'.$search_string_hash, $results, false, 60);
}
if ($results !== false && $results !== array())
@@ -69,25 +69,28 @@
$tpl->display("head.tpl");
// Display the results
-$tpl->assign('servers_total', $memcache->get('servers_total'));
-$tpl->assign('servers_mp3', $memcache->get('servers_'.CONTENT_TYPE_MP3));
-$tpl->assign('servers_vorbis', $memcache->get('servers_'.CONTENT_TYPE_OGG_VORBIS));
-$tpl->assign('tag_cloud', $memcache->get('prod_tagcloud'));
+$tpl->assign('servers_total', $memcache->get(ENVIRONMENT.'_servers_total'));
+$tpl->assign('servers_mp3', $memcache->get(ENVIRONMENT.'_servers_'.CONTENT_TYPE_MP3));
+$tpl->assign('servers_vorbis', $memcache->get(ENVIRONMENT.'_servers_'.CONTENT_TYPE_OGG_VORBIS));
+$tpl->assign('tag_cloud', $memcache->get(ENVIRONMENT.'_tagcloud'));
$tpl->display('search.tpl');
// Footer
-$tpl->assign('generation_time', (microtime(true) - $begin_time) * 1000);
-$tpl->assign('sql_queries', isset($db) ? $db->queries : 0);
-if (isset($db))
+if (ENVIRONMENT != 'prod')
{
- $tpl->assign('sql_debug', $db->log);
+ $tpl->assign('generation_time', (microtime(true) - $begin_time) * 1000);
+ $tpl->assign('sql_queries', isset($db) ? $db->queries : 0);
+ if (isset($db))
+ {
+ $tpl->assign('sql_debug', $db->log);
+ }
+ $tpl->assign('mc_gets', isset($memcache) ? $memcache->gets : 0);
+ $tpl->assign('mc_sets', isset($memcache) ? $memcache->sets : 0);
+ if (isset($memcache))
+ {
+ $tpl->assign('mc_debug', $memcache->log);
+ }
}
-$tpl->assign('mc_gets', isset($memcache) ? $memcache->gets : 0);
-$tpl->assign('mc_sets', isset($memcache) ? $memcache->sets : 0);
-if (isset($memcache))
-{
- $tpl->assign('mc_debug', $memcache->log);
-}
$tpl->display('foot.tpl');
?>
Modified: branches/dir.xiph.org/by_genre.php
===================================================================
--- branches/dir.xiph.org/by_genre.php 2008-04-07 19:22:21 UTC (rev 14667)
+++ branches/dir.xiph.org/by_genre.php 2008-04-07 19:47:05 UTC (rev 14668)
@@ -22,7 +22,7 @@
$search_string_hash = jenkins_hash_hex($search_string);
// Get the data from the Memcache server
- if (($results = $memcache->get('prod_search_genre_'.$search_string_hash)) === false)
+ if (($results = $memcache->get(ENVIRONMENT.'_search_genre_'.$search_string_hash)) === false)
{
// Database connection
$db = DirXiphOrgDBC::getInstance();
@@ -48,7 +48,7 @@
}
// Cache the resultset
- $memcache->set('prod_search_genre_'.$search_string_hash, $results, false, 60);
+ $memcache->set(ENVIRONMENT.'_search_genre_'.$search_string_hash, $results, false, 60);
}
if ($results !== false && $results !== array())
@@ -70,7 +70,7 @@
else
{
// Tag cloud
- $tpl->assign('tag_cloud', $memcache->get('prod_tagcloud'));
+ $tpl->assign('tag_cloud', $memcache->get(ENVIRONMENT.'_tagcloud'));
$tpl->assign('display_tag_cloud', true);
}
@@ -78,25 +78,28 @@
$tpl->display("head.tpl");
// Display the results
-$tpl->assign('servers_total', $memcache->get('servers_total'));
-$tpl->assign('servers_mp3', $memcache->get('servers_'.CONTENT_TYPE_MP3));
-$tpl->assign('servers_vorbis', $memcache->get('servers_'.CONTENT_TYPE_OGG_VORBIS));
-$tpl->assign('tag_cloud', $memcache->get('prod_tagcloud'));
+$tpl->assign('servers_total', $memcache->get(ENVIRONMENT.'_servers_total'));
+$tpl->assign('servers_mp3', $memcache->get(ENVIRONMENT.'_servers_'.CONTENT_TYPE_MP3));
+$tpl->assign('servers_vorbis', $memcache->get(ENVIRONMENT.'_servers_'.CONTENT_TYPE_OGG_VORBIS));
+$tpl->assign('tag_cloud', $memcache->get(ENVIRONMENT.'_tagcloud'));
$tpl->display('search.tpl');
// Footer
-$tpl->assign('generation_time', (microtime(true) - $begin_time) * 1000);
-$tpl->assign('sql_queries', isset($db) ? $db->queries : 0);
-if (isset($db))
+if (ENVIRONMENT != 'prod')
{
- $tpl->assign('sql_debug', $db->log);
+ $tpl->assign('generation_time', (microtime(true) - $begin_time) * 1000);
+ $tpl->assign('sql_queries', isset($db) ? $db->queries : 0);
+ if (isset($db))
+ {
+ $tpl->assign('sql_debug', $db->log);
+ }
+ $tpl->assign('mc_gets', isset($memcache) ? $memcache->gets : 0);
+ $tpl->assign('mc_sets', isset($memcache) ? $memcache->sets : 0);
+ if (isset($memcache))
+ {
+ $tpl->assign('mc_debug', $memcache->log);
+ }
}
-$tpl->assign('mc_gets', isset($memcache) ? $memcache->gets : 0);
-$tpl->assign('mc_sets', isset($memcache) ? $memcache->sets : 0);
-if (isset($memcache))
-{
- $tpl->assign('mc_debug', $memcache->log);
-}
$tpl->display('foot.tpl');
?>
Modified: branches/dir.xiph.org/cgi-bin/yp.php
===================================================================
--- branches/dir.xiph.org/cgi-bin/yp.php 2008-04-07 19:22:21 UTC (rev 14667)
+++ branches/dir.xiph.org/cgi-bin/yp.php 2008-04-07 19:47:05 UTC (rev 14668)
@@ -168,10 +168,10 @@
// Increment the "total servers" key in memcache
if (!$memcache->increment('servers_total'))
{
- $memcache->set('servers_total', 1);
+ $memcache->set(ENVIRONMENT.'_servers_total', 1);
}
$ct_id = content_type_lookup($media_type);
- $ct_key = 'servers_'.intval($ct_id);
+ $ct_key = ENVIRONMENT.'_servers_'.intval($ct_id);
if (!$memcache->increment($ct_key))
{
$memcache->set($ct_key, 1);
Modified: branches/dir.xiph.org/cronjobs/check_servers.php
===================================================================
--- branches/dir.xiph.org/cronjobs/check_servers.php 2008-04-07 19:22:21 UTC (rev 14667)
+++ branches/dir.xiph.org/cronjobs/check_servers.php 2008-04-07 19:47:05 UTC (rev 14668)
@@ -1,12 +1,7 @@
<?php
// Inclusions
-include_once(dirname(__FILE__).'/../inc/class.db.php');
-include_once(dirname(__FILE__).'/../inc/class.mc.php');
-include_once(dirname(__FILE__).'/../inc/class.izterator.php');
-include_once(dirname(__FILE__).'/../inc/class.izteratorbuilder.php');
-include_once(dirname(__FILE__).'/../inc/inc.db.php');
-include_once(dirname(__FILE__).'/../inc/inc.mc.php');
+include_once(dirname(__FILE__).'/../inc/prepend.php');
class ToDeleteException extends Exception { }
Modified: branches/dir.xiph.org/cronjobs/generate_tagcloud.php
===================================================================
--- branches/dir.xiph.org/cronjobs/generate_tagcloud.php 2008-04-07 19:22:21 UTC (rev 14667)
+++ branches/dir.xiph.org/cronjobs/generate_tagcloud.php 2008-04-07 19:47:05 UTC (rev 14668)
@@ -1,14 +1,7 @@
<?php
-// Classes
-include_once(dirname(__FILE__).'/../inc/class.db.php');
-include_once(dirname(__FILE__).'/../inc/class.mc.php');
-include_once(dirname(__FILE__).'/../inc/class.izterator.php');
-include_once(dirname(__FILE__).'/../inc/class.izteratorbuilder.php');
-
// Inclusions
-include_once(dirname(__FILE__).'/../inc/inc.db.php');
-include_once(dirname(__FILE__).'/../inc/inc.mc.php');
+include_once(dirname(__FILE__).'/../inc/prepend.php');
// Database connection
$db = DirXiphOrgDBC::getInstance();
Modified: branches/dir.xiph.org/cronjobs/generate_top.php
===================================================================
--- branches/dir.xiph.org/cronjobs/generate_top.php 2008-04-07 19:22:21 UTC (rev 14667)
+++ branches/dir.xiph.org/cronjobs/generate_top.php 2008-04-07 19:47:05 UTC (rev 14668)
@@ -1,14 +1,7 @@
<?php
-// Classes
-include_once(dirname(__FILE__).'/../inc/class.db.php');
-include_once(dirname(__FILE__).'/../inc/class.mc.php');
-include_once(dirname(__FILE__).'/../inc/class.izterator.php');
-include_once(dirname(__FILE__).'/../inc/class.izteratorbuilder.php');
-
// Inclusions
-include_once(dirname(__FILE__).'/../inc/inc.db.php');
-include_once(dirname(__FILE__).'/../inc/inc.mc.php');
+include_once(dirname(__FILE__).'/../inc/prepend.php');
// Database connection
$db = DirXiphOrgDBC::getInstance();
Modified: branches/dir.xiph.org/cronjobs/update_stats.php
===================================================================
--- branches/dir.xiph.org/cronjobs/update_stats.php 2008-04-07 19:22:21 UTC (rev 14667)
+++ branches/dir.xiph.org/cronjobs/update_stats.php 2008-04-07 19:47:05 UTC (rev 14668)
@@ -1,17 +1,7 @@
<?php
-// Classes
-include_once(dirname(__FILE__).'/../inc/class.db.php');
-include_once(dirname(__FILE__).'/../inc/class.mc.php');
-include_once(dirname(__FILE__).'/../inc/class.izterator.php');
-include_once(dirname(__FILE__).'/../inc/class.izteratorbuilder.php');
-
-// Libraries
-include_once(dirname(__FILE__).'/../inc/lib.dir.php');
-
// Inclusions
-include_once(dirname(__FILE__).'/../inc/inc.db.php');
-include_once(dirname(__FILE__).'/../inc/inc.mc.php');
+include_once(dirname(__FILE__).'/../inc/prepend.php');
// Database connection
$db = DirXiphOrgDBC::getInstance();
@@ -27,19 +17,19 @@
$where = sprintf($where_pattern, CONTENT_TYPE_MP3);
$query = sprintf($query_pattern, $where);
$count = $db->singleQuery($query)->current('count');
-$memcache->set('servers_'.CONTENT_TYPE_MP3, $count, false, 600); // 10 minutes
+$memcache->set(ENVIRONMENT.'_servers_'.CONTENT_TYPE_MP3, $count, false, 600); // 10 minutes
// Vorbis
$where = array();
$where = sprintf($where_pattern, CONTENT_TYPE_OGG_VORBIS);
$query = sprintf($query_pattern, $where);
$count = $db->singleQuery($query)->current('count');
-$memcache->set('servers_'.CONTENT_TYPE_OGG_VORBIS, $count, false, 600); // 10 minutes
+$memcache->set(ENVIRONMENT.'_servers_'.CONTENT_TYPE_OGG_VORBIS, $count, false, 600); // 10 minutes
// Total
$query = sprintf($query_pattern, '1');
$count = $db->singleQuery($query)->current('count');
-$memcache->set('servers_total', $count, false, 600); // 10 minutes
+$memcache->set(ENVIRONMENT.'_servers_total', $count, false, 600); // 10 minutes
echo("OK.\n");
Modified: branches/dir.xiph.org/inc/inc.db.php
===================================================================
--- branches/dir.xiph.org/inc/inc.db.php 2008-04-07 19:22:21 UTC (rev 14667)
+++ branches/dir.xiph.org/inc/inc.db.php 2008-04-07 19:47:05 UTC (rev 14668)
@@ -4,7 +4,7 @@
* Connection parameters for dir.xiph.org
**/
-if (ENVIRONEMENT == 'preprod')
+if (ENVIRONMENT == 'preprod')
{
define('CP_DB_HOST', 'localhost');
define('CP_DB_USER', 'dir_xiph_org_t');
@@ -18,6 +18,10 @@
define('CP_DB_PASS', '5wCjLEVmAJnmM');
define('CP_DB_NAME', 'dir_xiph_org');
}
+else
+{
+ die("Unable to do this on test atm.\n");
+}
/**
* Database connection class with semi-hard-coded (?!) login and stuff.
Modified: branches/dir.xiph.org/inc/prepend.php
===================================================================
--- branches/dir.xiph.org/inc/prepend.php 2008-04-07 19:22:21 UTC (rev 14667)
+++ branches/dir.xiph.org/inc/prepend.php 2008-04-07 19:47:05 UTC (rev 14668)
@@ -3,8 +3,12 @@
class BadIDException extends Exception { }
class EnvironmentUndefinedException extends Exception { }
-if ($_SERVER['SERVER_NAME'] == 'directory-test.radiopytagor.net')
+if (getenv('ENVIRONMENT') !== false)
{
+ define('ENVIRONMENT', strtolower(getenv('ENVIRONMENT')));
+}
+elseif ($_SERVER['SERVER_NAME'] == 'directory-test.radiopytagor.net')
+{
define('ENVIRONMENT', 'preprod');
}
elseif ($_SERVER['SERVER_NAME'] == 'directory.radiopytagor.net'
Modified: branches/dir.xiph.org/index.php
===================================================================
--- branches/dir.xiph.org/index.php 2008-04-07 19:22:21 UTC (rev 14667)
+++ branches/dir.xiph.org/index.php 2008-04-07 19:47:05 UTC (rev 14668)
@@ -9,23 +9,26 @@
$tpl->display("head.tpl");
// Get the data from the Memcache server
-$top = $memcache->get('prod_home_top');
+$top = $memcache->get(ENVIRONMENT.'_home_top');
$top = array_map(array('Mountpoint', 'retrieveByPk'), $top);
$tpl->assign('data', $top);
-$tpl->assign('servers_total', $memcache->get('servers_total'));
-$tpl->assign('servers_mp3', $memcache->get('servers_'.CONTENT_TYPE_MP3));
-$tpl->assign('servers_vorbis', $memcache->get('servers_'.CONTENT_TYPE_OGG_VORBIS));
-$tpl->assign('tag_cloud', $memcache->get('prod_tagcloud'));
+$tpl->assign('servers_total', $memcache->get(ENVIRONMENT.'_servers_total'));
+$tpl->assign('servers_mp3', $memcache->get(ENVIRONMENT.'_servers_'.CONTENT_TYPE_MP3));
+$tpl->assign('servers_vorbis', $memcache->get(ENVIRONMENT.'_servers_'.CONTENT_TYPE_OGG_VORBIS));
+$tpl->assign('tag_cloud', $memcache->get(ENVIRONMENT.'_tagcloud'));
$tpl->display('index.tpl');
// Footer
-$tpl->assign('generation_time', (microtime(true) - $begin_time) * 1000);
-$tpl->assign('sql_queries', isset($db) ? $db->queries : 0);
-$tpl->assign('mc_gets', isset($memcache) ? $memcache->gets : 0);
-$tpl->assign('mc_sets', isset($memcache) ? $memcache->sets : 0);
-if (isset($memcache))
+if (ENVIRONMENT != 'prod')
{
- $tpl->assign('mc_debug', $memcache->log);
+ $tpl->assign('generation_time', (microtime(true) - $begin_time) * 1000);
+ $tpl->assign('sql_queries', isset($db) ? $db->queries : 0);
+ $tpl->assign('mc_gets', isset($memcache) ? $memcache->gets : 0);
+ $tpl->assign('mc_sets', isset($memcache) ? $memcache->sets : 0);
+ if (isset($memcache))
+ {
+ $tpl->assign('mc_debug', $memcache->log);
+ }
}
$tpl->display('foot.tpl');
Modified: branches/dir.xiph.org/listen.php
===================================================================
--- branches/dir.xiph.org/listen.php 2008-04-07 19:22:21 UTC (rev 14667)
+++ branches/dir.xiph.org/listen.php 2008-04-07 19:47:05 UTC (rev 14668)
@@ -70,7 +70,7 @@
$memcache = DirXiphOrgMCC::getInstance();
// Check the memcache server
-$playlist = $memcache->get('prod_playlist_'.$p_id);
+$playlist = $memcache->get(ENVIRONMENT.'_playlist_'.$p_id);
if ($playlist === false)
{
// Database connection
@@ -92,7 +92,7 @@
}
// Store into memcache
- $memcache->set('prod_playlist_'.$p_id, $playlist, 60);
+ $memcache->set(ENVIRONMENT.'_playlist_'.$p_id, $playlist, 60);
}
catch (SQLNoResultException $e)
{
Modified: branches/dir.xiph.org/search.php
===================================================================
--- branches/dir.xiph.org/search.php 2008-04-07 19:22:21 UTC (rev 14667)
+++ branches/dir.xiph.org/search.php 2008-04-07 19:47:05 UTC (rev 14668)
@@ -59,7 +59,7 @@
$search_in = implode(', ', $search_in);
// Get the data from the Memcache server
- if (($results = $memcache->get('prod_search_'.$search_string_hash)) === false)
+ if (($results = $memcache->get(ENVIRONMENT.'_search_'.$search_string_hash)) === false)
{
// Cache miss. Now query the database.
try
@@ -86,7 +86,7 @@
}
// Cache the resultset
- $memcache->set('prod_search_'.$search_string_hash, $results,
+ $memcache->set(ENVIRONMENT.'_search_'.$search_string_hash, $results,
false, 60);
}
@@ -113,25 +113,28 @@
$tpl->display("head.tpl");
// Display the results
-$tpl->assign('servers_total', $memcache->get('servers_total'));
-$tpl->assign('servers_mp3', $memcache->get('servers_'.CONTENT_TYPE_MP3));
-$tpl->assign('servers_vorbis', $memcache->get('servers_'.CONTENT_TYPE_OGG_VORBIS));
-$tpl->assign('tag_cloud', $memcache->get('prod_tagcloud'));
+$tpl->assign('servers_total', $memcache->get(ENVIRONMENT.'_servers_total'));
+$tpl->assign('servers_mp3', $memcache->get(ENVIRONMENT.'_servers_'.CONTENT_TYPE_MP3));
+$tpl->assign('servers_vorbis', $memcache->get(ENVIRONMENT.'_servers_'.CONTENT_TYPE_OGG_VORBIS));
+$tpl->assign('tag_cloud', $memcache->get(ENVIRONMENT.'_tagcloud'));
$tpl->display('search.tpl');
// Footer
-$tpl->assign('generation_time', (microtime(true) - $begin_time) * 1000);
-$tpl->assign('sql_queries', isset($db) ? $db->queries : 0);
-if (isset($db))
+if (ENVIRONMENT != 'prod')
{
- $tpl->assign('sql_debug', $db->log);
+ $tpl->assign('generation_time', (microtime(true) - $begin_time) * 1000);
+ $tpl->assign('sql_queries', isset($db) ? $db->queries : 0);
+ if (isset($db))
+ {
+ $tpl->assign('sql_debug', $db->log);
+ }
+ $tpl->assign('mc_gets', isset($memcache) ? $memcache->gets : 0);
+ $tpl->assign('mc_sets', isset($memcache) ? $memcache->sets : 0);
+ if (isset($memcache))
+ {
+ $tpl->assign('mc_debug', $memcache->log);
+ }
}
-$tpl->assign('mc_gets', isset($memcache) ? $memcache->gets : 0);
-$tpl->assign('mc_sets', isset($memcache) ? $memcache->sets : 0);
-if (isset($memcache))
-{
- $tpl->assign('mc_debug', $memcache->log);
-}
$tpl->display('foot.tpl');
?>
More information about the commits
mailing list