forked from vitalif/vitastor
Do not die in mon on bad JSON in etcd
parent
49ec8c7c63
commit
faa871090f
|
@ -222,6 +222,7 @@ class Mon
|
||||||
this.etcd_urls.push(scheme+'://'+url);
|
this.etcd_urls.push(scheme+'://'+url);
|
||||||
}
|
}
|
||||||
this.verbose = config.verbose || 0;
|
this.verbose = config.verbose || 0;
|
||||||
|
this.config = {};
|
||||||
this.etcd_prefix = config.etcd_prefix || '/vitastor';
|
this.etcd_prefix = config.etcd_prefix || '/vitastor';
|
||||||
this.etcd_prefix = this.etcd_prefix.replace(/\/\/+/g, '/').replace(/^\/?(.*[^\/])\/?$/, '/$1');
|
this.etcd_prefix = this.etcd_prefix.replace(/\/\/+/g, '/').replace(/^\/?(.*[^\/])\/?$/, '/$1');
|
||||||
this.etcd_start_timeout = (config.etcd_start_timeout || 5) * 1000;
|
this.etcd_start_timeout = (config.etcd_start_timeout || 5) * 1000;
|
||||||
|
@ -892,7 +893,15 @@ class Mon
|
||||||
console.log('Bad key in etcd: '+kv.key+' = '+kv.value);
|
console.log('Bad key in etcd: '+kv.key+' = '+kv.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
kv.value = kv.value ? JSON.parse(kv.value) : null;
|
kv.value = kv.value ? JSON.parse(kv.value) : null;
|
||||||
|
}
|
||||||
|
catch (e)
|
||||||
|
{
|
||||||
|
console.log('Bad key in etcd: '+kv.key+' = '+kv.value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
key = key.split('/');
|
key = key.split('/');
|
||||||
let cur = this.state;
|
let cur = this.state;
|
||||||
for (let i = 0; i < key.length-1; i++)
|
for (let i = 0; i < key.length-1; i++)
|
||||||
|
|
Loading…
Reference in New Issue