Use console.error() instead of debug() if we have an error

This commit is contained in:
Johannes Zellner
2014-08-06 22:04:52 -07:00
parent 68372e9b3e
commit 427b270ca1
2 changed files with 12 additions and 14 deletions
+9 -10
View File
@@ -4,6 +4,8 @@
'use strict';
require('supererror');
var assert = require('assert'),
Docker = require('dockerode'),
superagent = require('superagent'),
@@ -11,16 +13,13 @@ var assert = require('assert'),
os = require('os'),
safe = require('safetydance'),
appdb = require('./appdb.js'),
Writable = require('stream').Writable,
debug = require('debug')('box:apptask'),
fs = require('fs'),
child_process = require('child_process'),
path = require('path'),
net = require('net'),
rimraf = require('rimraf'),
config = require('../config.js'),
database = require('./database.js'),
HttpError = require('./httperror.js'),
ejs = require('ejs'),
appFqdn = require('./apps').appFqdn;
@@ -97,7 +96,7 @@ function configureNginx(app, httpPort, callback) {
function unconfigureNginx(app, callback) {
var nginxConfigFilename = path.join(config.nginxAppConfigDir, app.location + '.conf');
if (!safe.fs.unlinkSync(nginxConfigFilename)) {
debug('Error removing nginx configuration ' + safe.error);
console.error('Error removing nginx configuration ' + safe.error);
return callback(safe.error);
}
@@ -140,7 +139,7 @@ function downloadImage(app, callback) {
if (data.status) {
debug('Progress: ' + data.status); // progressDetail { current, total }
} else if (data.error) {
debug('Error detail:' + data.errorDetail.message);
console.error('Error detail:' + data.errorDetail.message);
}
});
@@ -221,7 +220,7 @@ function createVolume(app, callback) {
function deleteVolume(app, callback) {
child_process.exec('sudo ' + __dirname + '/rmappdir.sh ' + app.id, function (error, stdout, stderr) {
if (error) debug('Error removing volume', error);
if (error) console.error('Error removing volume', error);
return callback(error);
});
}
@@ -308,9 +307,9 @@ function unregisterSubdomain(app, callback) {
.query({ token: config.token })
.end(function (error, res) {
if (error) {
debug('Error making request: ' + error.message);
console.error('Error making request: ' + error.message);
} else if (res.status !== 200) {
debug('Error unregistering subdomain:' + res.body.status + ' ' + res.body.message);
console.error('Error unregistering subdomain:' + res.body.status + ' ' + res.body.message);
}
callback(null);
@@ -469,7 +468,7 @@ function runApp(app, callback) {
startContainer(app, portBindings, function (error) {
if (error) {
debug('Error creating container:' + error);
console.error('Error creating container:' + error);
return updateApp(app, { runState: appdb.RSTATE_ERROR }, callback);
}
@@ -490,7 +489,7 @@ function start(appId, callback) {
install(app, function (error) {
if (error) {
debug('Error installing app:', error);
console.error('Error installing app:', error);
return updateApp(app, { installationState: appdb.ISTATE_ERROR }, callback);
}
+3 -4
View File
@@ -4,7 +4,6 @@
var sqlite3 = require('sqlite3'),
fs = require('fs'),
mkdirp = require('mkdirp'),
path = require('path'),
debug = require('debug')('box:database'),
DatabaseError = require('./databaseerror'),
@@ -29,13 +28,13 @@ var connectionPool = [ ],
databaseFileName = null,
db = null;
var NOOP_CALLBACK = function (error) { if (error) console.error(error); assert(!error); }
var NOOP_CALLBACK = function (error) { if (error) console.error(error); assert(!error); };
function initialize(callback) {
databaseFileName = config.configRoot + '/config.sqlite.db';
db = new sqlite3.Database(databaseFileName);
db.on('error', function (error) {
console.log('Database error in ' + databaseFileName + ':' + JSON.stringify(error));
console.error('Database error in ' + databaseFileName + ':' + JSON.stringify(error));
});
return callback(null);
@@ -59,7 +58,7 @@ function create(callback) {
db = new sqlite3.Database(databaseFileName);
db.on('error', function (error) {
console.log('Database error in ' + databaseFileName + ':' + JSON.stringify(error));
console.error('Database error in ' + databaseFileName + ':' + JSON.stringify(error));
});
debug('Database created at ' + databaseFileName);