Windshaft-cartodb/tools/reset_styles

36 lines
860 B
Plaintext
Raw Normal View History

#!/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);
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-21 18:58:34 +08:00
processNext();
});
});