Merge pull request #490 from resin-io/486-capture-init-errors

log unhandled exceptions
This commit is contained in:
Eugene Mirotin 2017-04-21 23:11:56 +03:00 committed by GitHub
commit 2e042499af
6 changed files with 19 additions and 12 deletions

View File

@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/). This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- Capture and report errors happening during the program initialization, like parsing invalid YAML config
## [5.7.2] - 2017-04-18 ## [5.7.2] - 2017-04-18
### Fixed ### Fixed

View File

@ -53,12 +53,12 @@ module.exports = {
} }
], ],
action: function(params, options, done) { action: function(params, options, done) {
var Promise, child_process, patterns, resin, settings, verbose; var Promise, child_process, patterns, proxyUrl, resin, verbose;
child_process = require('child_process'); child_process = require('child_process');
Promise = require('bluebird'); Promise = require('bluebird');
resin = require('resin-sdk-preconfigured'); resin = require('resin-sdk-preconfigured');
settings = require('resin-settings-client');
patterns = require('../utils/patterns'); patterns = require('../utils/patterns');
proxyUrl = resin.settings.get('proxyUrl');
if (options.port == null) { if (options.port == null) {
options.port = 22; options.port = 22;
} }
@ -92,7 +92,7 @@ module.exports = {
} }
return Promise["try"](function() { return Promise["try"](function() {
var command, subShellCommand; var command, subShellCommand;
command = "ssh " + verbose + " -t -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ControlMaster=no -p " + options.port + " " + username + "@ssh." + (settings.get('proxyUrl')) + " enter " + uuid + " " + containerId; command = "ssh " + verbose + " -t -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ControlMaster=no -p " + options.port + " " + username + "@ssh." + proxyUrl + " enter " + uuid + " " + containerId;
subShellCommand = getSubShellCommand(command); subShellCommand = getSubShellCommand(command);
return child_process.spawn(subShellCommand.program, subShellCommand.args, { return child_process.spawn(subShellCommand.program, subShellCommand.args, {
stdio: 'inherit' stdio: 'inherit'

View File

@ -24,7 +24,10 @@ Raven.disableConsoleAlerts();
Raven.config(require('./config').sentryDsn, { Raven.config(require('./config').sentryDsn, {
captureUnhandledRejections: true, captureUnhandledRejections: true,
release: require('../package.json').version release: require('../package.json').version
}).install(); }).install(function(logged, error) {
console.error(error);
return process.exit(1);
});
_ = require('lodash'); _ = require('lodash');

View File

@ -70,8 +70,8 @@ module.exports =
child_process = require('child_process') child_process = require('child_process')
Promise = require 'bluebird' Promise = require 'bluebird'
resin = require('resin-sdk-preconfigured') resin = require('resin-sdk-preconfigured')
settings = require('resin-settings-client')
patterns = require('../utils/patterns') patterns = require('../utils/patterns')
proxyUrl = resin.settings.get('proxyUrl')
if not options.port? if not options.port?
options.port = 22 options.port = 22
@ -92,7 +92,8 @@ module.exports =
Promise.props Promise.props
username: resin.auth.whoami() username: resin.auth.whoami()
uuid: device.uuid # get full uuid uuid: device.uuid
# get full uuid
containerId: resin.models.device.getApplicationInfo(device.uuid).get('containerId') containerId: resin.models.device.getApplicationInfo(device.uuid).get('containerId')
.then ({ username, uuid, containerId }) -> .then ({ username, uuid, containerId }) ->
throw new Error('Did not find running application container') if not containerId? throw new Error('Did not find running application container') if not containerId?
@ -102,7 +103,7 @@ module.exports =
-o StrictHostKeyChecking=no \ -o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \ -o UserKnownHostsFile=/dev/null \
-o ControlMaster=no \ -o ControlMaster=no \
-p #{options.port} #{username}@ssh.#{settings.get('proxyUrl')} enter #{uuid} #{containerId}" -p #{options.port} #{username}@ssh.#{proxyUrl} enter #{uuid} #{containerId}"
subShellCommand = getSubShellCommand(command) subShellCommand = getSubShellCommand(command)
child_process.spawn subShellCommand.program, subShellCommand.args, child_process.spawn subShellCommand.program, subShellCommand.args,

View File

@ -16,11 +16,12 @@ limitations under the License.
Raven = require('raven') Raven = require('raven')
Raven.disableConsoleAlerts() Raven.disableConsoleAlerts()
Raven.config( Raven.config require('./config').sentryDsn,
require('./config').sentryDsn
captureUnhandledRejections: true captureUnhandledRejections: true
release: require('../package.json').version release: require('../package.json').version
).install() .install (logged, error) ->
console.error(error)
process.exit(1)
_ = require('lodash') _ = require('lodash')
Promise = require('bluebird') Promise = require('bluebird')

View File

@ -44,7 +44,6 @@
"etcher-image-write": "^9.0.3", "etcher-image-write": "^9.0.3",
"inquirer": "^3.0.6", "inquirer": "^3.0.6",
"is-root": "^1.0.0", "is-root": "^1.0.0",
"js-yaml": "^3.7.0",
"lodash": "^3.10.0", "lodash": "^3.10.0",
"mixpanel": "^0.4.0", "mixpanel": "^0.4.0",
"moment": "^2.12.0", "moment": "^2.12.0",
@ -63,7 +62,6 @@
"resin-image-fs": "^2.1.2", "resin-image-fs": "^2.1.2",
"resin-image-manager": "^4.1.1", "resin-image-manager": "^4.1.1",
"resin-sdk-preconfigured": "^6.0.0", "resin-sdk-preconfigured": "^6.0.0",
"resin-settings-client": "^3.5.0",
"resin-sync": "^7.0.0", "resin-sync": "^7.0.0",
"rimraf": "^2.4.3", "rimraf": "^2.4.3",
"rindle": "^1.0.0", "rindle": "^1.0.0",