Skip to content

Commit

Permalink
improve error in status function, ref cozy#78
Browse files Browse the repository at this point in the history
  • Loading branch information
poupotte committed Jun 8, 2015
1 parent a8956c8 commit dfbf5a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 15 additions & 3 deletions lib/application.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,24 @@ manifest =

# Callback all application stored in database
module.exports.getApps = (callback) ->
homeClient.get "api/applications/", (err, res, apps) ->
homeClient.get "api/applications/", (error, res, apps) ->
if apps? and apps.rows?
callback null, apps.rows
else
callback makeError(err, apps)

# Check if couch is available
helpers.clients['couch'].get '', (err, res, body) ->
if err or not res? or res.statusCode isnt 200
log.error "couchDB isn't available"
# Check if data-system is available
helpers.clients['ds'].get '', (err, res, body) ->
if not res? or res.statusCode isnt 200
log.error "data-system isn't available"
# Check if home is available
helpers.clients['home'].get '', (err, res, body) ->
if not res? or res.statusCode isnt 200
log.error "home isn't available"
# Other pbs: credentials, view, ...
callback makeError(error, apps)

# Install application <app>
install = module.exports.install = (app, options, callback) ->
Expand Down
3 changes: 2 additions & 1 deletion lib/monitoring.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ module.exports.status = (callback) ->
funcs = []
application.getApps (err, apps) ->
if err?
callback makeError("Cannot retrieve apps", null)
log.error "Cannot retrieve apps"
callback err
else
for app in apps
if app.state is 'stopped'
Expand Down

0 comments on commit dfbf5a3

Please sign in to comment.