Add script to drop the XML element from all redis stored map styles
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.
This commit is contained in:
parent
dcbe051654
commit
adf1124e70
31
tools/reset_styles
Executable file
31
tools/reset_styles
Executable file
@ -0,0 +1,31 @@
|
||||
#!/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);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user