From f7aa4c32fc69ced8b79bfa57740146eace35c111 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 3 Feb 2015 20:31:34 -0500 Subject: [PATCH] dynamic Docker host --- src/Docker.js | 2 +- src/Main.js | 11 +++++++---- src/Setup.react.js | 5 ++++- src/SetupStore.js | 8 ++++++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Docker.js b/src/Docker.js index 6c8768bf2e..83c9786c12 100644 --- a/src/Docker.js +++ b/src/Docker.js @@ -12,7 +12,7 @@ var Docker = { return; } this._client = new dockerode({ - host: '192.168.59.103', + host: host, port: 2376, ca: fs.readFileSync(path.join(certDir, 'ca.pem')), cert: fs.readFileSync(path.join(certDir, 'cert.pem')), diff --git a/src/Main.js b/src/Main.js index 9c5c7dd205..3932675ff2 100644 --- a/src/Main.js +++ b/src/Main.js @@ -42,7 +42,10 @@ if (!window.location.hash.length || window.location.hash === '#/') { React.render(, document.body); }); SetupStore.run(function (err) { - router.transitionTo('setup'); + if (err) { + bugsnag.notify(err); + return; + } boot2docker.ip(function (err, ip) { if (err) console.log(err); docker.setHost(ip); @@ -52,14 +55,14 @@ if (!window.location.hash.length || window.location.hash === '#/') { }); }); } else { + router.run(function (Handler) { + React.render(, document.body); + }); boot2docker.ip(function (err, ip) { if (err) console.log(err); docker.setHost(ip); ContainerStore.init(function (err) { if (err) console.log(err); - router.run(function (Handler) { - React.render(, document.body); - }); }); }); } diff --git a/src/Setup.react.js b/src/Setup.react.js index 8df59eb28e..f9f3f7cbbb 100644 --- a/src/Setup.react.js +++ b/src/Setup.react.js @@ -20,13 +20,16 @@ var Setup = React.createClass({ componentWillMount: function () { SetupStore.on(SetupStore.PROGRESS_EVENT, this.update); SetupStore.on(SetupStore.STEP_EVENT, this.update); + SetupStore.on(SetupStore.ERROR_EVENT, this.update); }, componentDidMount: function () { + this.update(); }, update: function () { this.setState({ progress: SetupStore.stepProgress(), - step: SetupStore.stepName() + step: SetupStore.stepName(), + error: SetupStore.error() }); }, renderDownloadingVirtualboxStep: function () { diff --git a/src/SetupStore.js b/src/SetupStore.js index 32b14dc50d..24a6b04e4e 100644 --- a/src/SetupStore.js +++ b/src/SetupStore.js @@ -10,8 +10,8 @@ var setupUtil = require('./SetupUtil'); var packagejson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')); var _currentStep = null; -var _error = null; var _progress = 0; +var _error = error; var SetupStore = assign(EventEmitter.prototype, { PROGRESS_EVENT: 'setup_progress', @@ -170,6 +170,9 @@ var SetupStore = assign(EventEmitter.prototype, { stepProgress: function () { return _progress; }, + error: function () { + return _error; + }, run: function (callback) { var self = this; var steps = [this.downloadVirtualboxStep, this.installVirtualboxStep, this.cleanupKitematicStep, this.initBoot2DockerStep, this.startBoot2DockerStep]; @@ -189,8 +192,9 @@ var SetupStore = assign(EventEmitter.prototype, { self.emit(self.PROGRESS_EVENT, progress); }); }, function (err) { + _error = err; if (err) { - self.emit(self.ERROR_EVENT, _error); + self.emit(self.ERROR_EVENT); callback(err); } else { callback();