WARNING: as of grainstore-0.6.1 a map style with no XML will break the application, so do _not_ run this script unless you're sure about what you're doing.
32 lines
884 B
JavaScript
Executable File
32 lines
884 B
JavaScript
Executable File
#!/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) {
|
|
for (var i=0; i<matches.length; i++) {
|
|
var k = matches[i];
|
|
var i0 = i+1;
|
|
console.log("Resetting style " + i0 + " 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() {
|
|
console.log("done with style " + i0 + " / " + matches.length);
|
|
if ( i0 == matches.length ) process.exit(0);
|
|
});
|
|
});
|
|
}
|
|
});
|
|
});
|