2012-09-18 23:36:20 +08:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
// Reset redis-stored XML styles so that they are regenerated
|
|
|
|
// from CartoCSS on next tile request
|
|
|
|
|
|
|
|
var redis = require('redis')
|
|
|
|
|
|
|
|
var REDIS_PORT = 6379; // TODO: make a parameter
|
|
|
|
|
|
|
|
var dbnum = 0;
|
|
|
|
|
|
|
|
var client = redis.createClient(REDIS_PORT, 'localhost');
|
|
|
|
client.on('connect', function() {
|
|
|
|
client.select(dbnum);
|
|
|
|
client.keys('map_style|*', function(err, matches) {
|
2012-09-21 18:58:34 +08:00
|
|
|
|
|
|
|
processNext = function() {
|
|
|
|
if ( ! matches.length ) process.exit(0);
|
|
|
|
var k = matches.shift();
|
|
|
|
console.log("Resetting XML in key: " + k);
|
2012-09-18 23:36:20 +08:00
|
|
|
client.get(k, function(err, val) {
|
|
|
|
if ( err ) throw err;
|
|
|
|
val = JSON.parse(val);
|
|
|
|
delete val.xml;
|
|
|
|
client.set(k, JSON.stringify(val), function() {
|
2012-09-21 18:58:34 +08:00
|
|
|
console.log("done with style " + k);
|
|
|
|
processNext();
|
2012-09-18 23:36:20 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2012-09-21 18:58:34 +08:00
|
|
|
|
|
|
|
processNext();
|
|
|
|
|
2012-09-18 23:36:20 +08:00
|
|
|
});
|
|
|
|
});
|