Permalink
Browse files

Various error corrections

  • Loading branch information...
1 parent 85d6fde commit ebdb3245fb45680ecfb6aefc1ad50fc3cc141565 @jhs committed Feb 23, 2011
Showing with 21 additions and 13 deletions.
  1. +14 −12 audit_couchdb.js
  2. +1 −1 lib.js
  3. +6 −0 probe_couchdb.js
View
@@ -41,18 +41,20 @@ function CouchAudit(url) {
})
self.on('config', function(config) {
- // One thing to check is how many admins there are.
- var admin_names = Object.keys(config.admins || {});
- if(admin_names.length < 1)
- self.V({ level: 'high'
- , fact : 'This couch is in Admin Party'
- , hint : 'Log in to Futon (/_utils) and click "Fix this"'
- });
- else if(admin_names.length > 1)
- self.V({ level: 'medium'
- , fact : admin_names.length + " system admin accounts: " + JSON.stringify(admin_names)
- , hint : 'In production, admins should be used rarely or never, but yet you have more than one'
- });
+ if(config) {
+ // One thing to check is how many admins there are.
+ var admin_names = Object.keys(config.admins || {});
+ if(admin_names.length < 1)
+ self.V({ level: 'high'
+ , fact : 'This couch is in Admin Party'
+ , hint : 'Log in to Futon (/_utils) and click "Fix this"'
+ });
+ else if(admin_names.length > 1)
+ self.V({ level: 'medium'
+ , fact : admin_names.length + " system admin accounts: " + JSON.stringify(admin_names)
+ , hint : 'In production, admins should be used rarely or never, but yet you have more than one'
+ });
+ }
// Mark the config known for waiting functions.
self.known.config(null, config);
View
@@ -31,7 +31,7 @@ function getLogger(label) {
return log;
}
-var url_parts = /(https?:\/\/)?([^:]+:[^@]+@)?(.*)$/;
+var url_parts = /(https?:\/\/)([^:]+:[^@]+@)?(.*)$/;
function get_creds(url) {
var match = url_parts.exec(url);
View
@@ -309,6 +309,12 @@ Couch.prototype.start = function() {
self.log.debug("Pinging: " + self.url);
self.request({uri:self.url}, function(er, resp, body) {
if(er) throw er;
+ if(resp.statusCode === 401 || body.error === 'unauthorized') {
+ self.log.fatal('Not authorized: ' + self.url);
+ return;
+ //+ self.url);
+ }
+
if(resp.statusCode !== 200 || body.couchdb !== "Welcome")
throw new Error("Bad welcome from " + self.url + ": " + JSON.stringify(body));

0 comments on commit ebdb324

Please sign in to comment.