Navigation Menu

Skip to content

Commit

Permalink
[dist] update
Browse files Browse the repository at this point in the history
  • Loading branch information
Swaagie committed Oct 16, 2013
2 parents d709e96 + f2a9412 commit b974bb4
Show file tree
Hide file tree
Showing 9 changed files with 547 additions and 544 deletions.
19 changes: 19 additions & 0 deletions LICENSE
@@ -0,0 +1,19 @@
Copyright (c) 2013 Nodejitsu Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -20,7 +20,7 @@
- Allows for seamless deployment of your Node.js applications to the cloud
- Ships with use-full boilerplates and sample applications through [Node Apps](https://github.com/nodeapps) project integration
- Fully supports `npm` dependency resolution on deployment to [Nodejitsu](http://nodejitsu.com)
- Full support of [Nodejitu's API](https://github.com/nodejitsu/nodejitsu-api) ( a plethora of node.js goodies )
- Full support of [Nodejitsu's API](https://github.com/nodejitsu/nodejitsu-api) ( a plethora of node.js goodies )
- Integrated multi-level multi-transport logging support via [Winston](https://github.com/flatiron/winston)
- Too many to list... seek [further knowledge ](https://github.com/nodejitsu/handbook) or just try it out!

Expand Down
132 changes: 79 additions & 53 deletions lib/jitsu.js
Expand Up @@ -263,6 +263,11 @@ jitsu.setup = function (callback) {
jitsu.config.set('rejectUnauthorized', false);
}

var userAgent = jitsu.config.get('headers:user-agent');
if (!userAgent) {
jitsu.config.set('headers:user-agent', 'jitsu/' + jitsu.version);
}

['Users', 'Apps', 'Snapshots', 'Databases', 'Logs', 'Tokens'].forEach(function (key) {
var k = key.toLowerCase();
jitsu[k] = new jitsu.api[key](jitsu.config);
Expand Down Expand Up @@ -294,8 +299,50 @@ jitsu.setup = function (callback) {
//
jitsu.showError = function (command, err, shallow, skip) {
var username,
display,
errors,
stack;

//
// ### function unknownError(message, stack)
// Displays an unknown error by dumping the call `stack`
// and a given `message`.
//
function unknownError(message, stack) {
jitsu.log.error(message);
stack.split('\n').forEach(function (line) {
jitsu.log.error(line);
})
}

//
// ### function solenoidError(display)
// Displays a "solenoid" error.
//
function solenoidError(display) {
jitsu.log.error('Error starting application. This could be a user error.');
display.solenoid.split('\n').forEach(function (line) {
jitsu.log.error(line);
});
}

//
// ### function appError(display)
// Displays an "application" error.
//
function appError(display) {
if (display.output) {
jitsu.log.error('Error output from application. This is usually a user error.');
display.output.split('\n').forEach(function (line) {
jitsu.log.error(line);
})
}

return !display.solenoid
? unknownError(display.message, display.stack)
: solenoidError(display);
}

if (err.statusCode === 403) {
//jitsu.log.error('403 ' + err.result.error);
}
Expand All @@ -309,69 +356,41 @@ jitsu.showError = function (command, err, shallow, skip) {
}
else if (!skip) {
jitsu.log.error('Error running command ' + command.magenta);

if (!jitsu.config.get('nolog')) {
jitsu.logFile.log(err);
}

if (err.message) {
jitsu.log.error(err.message);
}

if (err.result) {
if (err.result.error) {
jitsu.log.error(err.result.error);
if (err.result.message) {
jitsu.log.error(err.result.message);
}

if (err.result.result && err.result.result.error) {
if (err.result.result.error.stderr || err.result.result.error.stdout) {
jitsu.log.error('');
jitsu.log.error('There was an error while attempting to start the app');
jitsu.log.error(err.result.result.error.message);
if (err.result.result.error.blame) {
jitsu.log.error(err.result.result.error.blame.message);
jitsu.log.error('');
jitsu.log.error('This type of error is usually a ' + err.result.result.error.blame.type + ' error.');
}

jitsu.log.error('Error output from app:');
jitsu.log.error('');
if (err.result.result.error.stdout) {
err.result.result.error.stdout.split('\n').forEach(function (line) {
jitsu.log.error(line);
});
}

if (err.result.result.error.stderr) {
err.result.result.error.stderr.split('\n').forEach(function (line) {
jitsu.log.error(line);
});
}
if (err.result.errors && Array.isArray(err.result.errors)) {
errors = {
connection: err.result.errors.filter(function (err) {
return err.blame === 'connection';
}),
application: err.result.errors.filter(function (err) {
return err.blame === 'application';
}),
solenoid: err.result.errors.filter(function (err) {
return err.blame === 'solenoid';
})
};

if (errors.application.length) {
return appError(errors.application[0]);
}
else if (err.result.result.error.stack) {
jitsu.log.error('There was an error while attempting to deploy the app');
jitsu.log.error('');
jitsu.log.error(err.result.result.error.message);

if (err.result.result.error.blame) {
jitsu.log.error(err.result.result.error.blame.message);
jitsu.log.error('');
jitsu.log.error('This type of error is usually a ' + err.result.result.error.blame.type + ' error.');
}

jitsu.log.error('Error output from Haibu:');
jitsu.log.error('');
stack = err.result.result.error.result || err.result.result.error.stack;
stack.split('\n').forEach(function (line) {
jitsu.log.error(line);
});
else if (errors.solenoid.length) {
return solenoidError(errors.solenoid[0])
}

return errors.connection.length
? unknownError('Error contacting drone(s):', errors.connection[0].stack)
: unknownError('Error returned from Nodejitsu:', err.result.errors[0].stack);
}
else if (err.result.stack) {
jitsu.log.warn('Error returned from Nodejitsu');
err.result.stack.split('\n').forEach(function (line) {
jitsu.log.error(line);
});
return unknownError('Error returned from Nodejitsu:', err.result.stack);
}
}
else {
Expand All @@ -383,16 +402,23 @@ jitsu.showError = function (command, err, shallow, skip) {
jitsu.log.info(
'jitsu\'s client request timed out before the server ' +
'could respond. Please increase your client timeout');
jitsu.log.help('(Example: `jitsu config set timeout 100000`)');
jitsu.log.help('(Example: `jitsu config set timeout 480000`)');
jitsu.log.help('This error may be due to network connection problems');
} else {
err.stack.split('\n').forEach(function (trace) {
jitsu.log.error(trace);
});
}

return;
}
}

if (err.message) {
jitsu.log.error(err.message);
}
}

jitsu.log.help("For help with this error contact Nodejitsu Support:");
jitsu.log.help(" webchat: <http://webchat.nodejitsu.com/>");
jitsu.log.help(" irc: <irc://chat.freenode.net/#nodejitsu>");
Expand Down
24 changes: 5 additions & 19 deletions lib/jitsu/commands/apps.js
Expand Up @@ -110,23 +110,6 @@ apps.deploy = function (callback) {
cloud.datacenter = jitsu.argv['datacenter'];
}

function promptLogin () {
jitsu.log.warn("No user is logged in");
jitsu.log.warn("Please authenticate");
jitsu.commands.users.login(function (err) {
return err
? callback(err)
: jitsu.commands.apps.deploy(callback);
});
}

//
// If not logged in require the user to authenticate before deploying
//
if (!jitsu.config.get('username') && !jitsu.config.get('password')) {
return promptLogin();
}

function startApp(err, existing) {
if (err) {
jitsu.log.error('Error creating snapshot for app ' + pkg.name.magenta);
Expand Down Expand Up @@ -899,7 +882,7 @@ apps.setdrones.usage = [
// to the app in the current directory.
//
apps.cloud = function (name, provider, datacenter) {
var providers = ['joyent', 'telefonica'],
var providers = ['joyent'],
args = utile.args(arguments),
callback = args.callback,
drones = jitsu.argv.drones,
Expand Down Expand Up @@ -1064,7 +1047,10 @@ apps.cloud.usage = [
'jitsu cloud [<name>]',
'',
'jitsu apps cloud [<name>] <provider> <datacenter> [<drones>]',
'jitsu cloud [<name>] <provider> <datacenter> [<drones>]'
'jitsu cloud [<name>] <provider> <datacenter> [<drones>]',
'',
'Options:',
'--ram RAM size to deploy to'
];

//
Expand Down

0 comments on commit b974bb4

Please sign in to comment.