mirror of https://github.com/docker/docs.git
Merge pull request #223 from kitematic/bug-fixes
Better Setup checking, add remove VM button to setup
This commit is contained in:
commit
7b8d6be11c
|
@ -1,6 +1,7 @@
|
|||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var dockerode = require('dockerode');
|
||||
var Promise = require('bluebird');
|
||||
|
||||
var Docker = {
|
||||
_host: null,
|
||||
|
@ -25,7 +26,34 @@ var Docker = {
|
|||
},
|
||||
host: function () {
|
||||
return this._host;
|
||||
},
|
||||
waitForConnection: Promise.coroutine(function * (tries, delay) {
|
||||
tries = tries || 5;
|
||||
delay = delay || 1000;
|
||||
var tryCount = 1;
|
||||
while (true) {
|
||||
console.log('Connecting: ' + tryCount + ' tries...');
|
||||
try {
|
||||
yield new Promise((resolve, reject) => {
|
||||
this._client.listContainers((err) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
} catch (err) {
|
||||
tryCount += 1;
|
||||
yield Promise.delay(delay);
|
||||
if (tryCount > tries) {
|
||||
throw new Error(err);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}),
|
||||
};
|
||||
|
||||
module.exports = Docker;
|
||||
|
|
12
src/Main.js
12
src/Main.js
|
@ -83,20 +83,12 @@ setInterval(function () {
|
|||
}, 14400000);
|
||||
|
||||
router.run(Handler => React.render(<Handler/>, document.body));
|
||||
SetupStore.setup().then(ip => {
|
||||
docker.setup(ip, machine.name());
|
||||
SetupStore.setup().then(() => {
|
||||
Menu.setApplicationMenu(Menu.buildFromTemplate(template()));
|
||||
ContainerStore.on(ContainerStore.SERVER_ERROR_EVENT, (err) => {
|
||||
bugsnag.notify(err);
|
||||
});
|
||||
ContainerStore.init(function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
bugsnag.notify('ContainerStoreError', 'Could not init containerstore', {
|
||||
error: err,
|
||||
machine: machine
|
||||
});
|
||||
}
|
||||
ContainerStore.init(function () {
|
||||
router.transitionTo('containers');
|
||||
});
|
||||
}).catch(err => {
|
||||
|
|
|
@ -6,7 +6,6 @@ var RetinaImage = require('react-retina-image');
|
|||
var Header = require('./Header.react');
|
||||
var Util = require('./Util');
|
||||
var metrics = require('./Metrics');
|
||||
var machine = require('./DockerMachine');
|
||||
|
||||
var Setup = React.createClass({
|
||||
mixins: [ Router.Navigation ],
|
||||
|
@ -14,7 +13,6 @@ var Setup = React.createClass({
|
|||
return {
|
||||
progress: 0,
|
||||
name: '',
|
||||
retrying: false
|
||||
};
|
||||
},
|
||||
componentWillMount: function () {
|
||||
|
@ -37,18 +35,18 @@ var Setup = React.createClass({
|
|||
SetupStore.retry();
|
||||
},
|
||||
handleErrorRetry: function () {
|
||||
this.setState({
|
||||
retrying: true
|
||||
});
|
||||
metrics.track('Setup Retried', {
|
||||
from: 'error'
|
||||
from: 'error',
|
||||
removeVM: false
|
||||
});
|
||||
machine.stop().finally(() => {
|
||||
this.setState({
|
||||
retrying: false
|
||||
});
|
||||
SetupStore.retry();
|
||||
SetupStore.retry(false);
|
||||
},
|
||||
handleErrorRemoveRetry: function () {
|
||||
metrics.track('Setup Retried', {
|
||||
from: 'error',
|
||||
removeVM: true
|
||||
});
|
||||
SetupStore.retry(true);
|
||||
},
|
||||
handleOpenWebsite: function () {
|
||||
Util.exec(['open', 'https://www.virtualbox.org/wiki/Downloads']);
|
||||
|
@ -128,7 +126,7 @@ var Setup = React.createClass({
|
|||
<h1>We're Sorry!</h1>
|
||||
<p>There seems to have been an unexpected error with Kitematic:</p>
|
||||
<p className="error">{this.state.error.message || this.state.error}</p>
|
||||
<p><button className="btn btn-action" disabled={this.state.retrying} onClick={this.handleErrorRetry}>Retry Setup</button></p>
|
||||
<p><button className="btn btn-action" onClick={this.handleErrorRetry}>Retry Setup</button> <button className="btn btn-action" onClick={this.handleErrorRemoveRetry}>Delete VM and Retry Setup</button></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -11,6 +11,7 @@ var assign = require('object-assign');
|
|||
var metrics = require('./Metrics');
|
||||
var bugsnag = require('bugsnag-js');
|
||||
var rimraf = require('rimraf');
|
||||
var docker = require('./Docker');
|
||||
|
||||
var _currentStep = null;
|
||||
var _error = null;
|
||||
|
@ -118,12 +119,26 @@ var SetupStore = assign(Object.create(EventEmitter.prototype), {
|
|||
cancelled: function () {
|
||||
return _cancelled;
|
||||
},
|
||||
retry: function () {
|
||||
retry: function (remove) {
|
||||
_error = null;
|
||||
_cancelled = false;
|
||||
if (_retryPromise) {
|
||||
_retryPromise.resolve();
|
||||
if (!_retryPromise) {
|
||||
return;
|
||||
}
|
||||
this.emit(this.ERROR_EVENT);
|
||||
if (remove) {
|
||||
machine.rm().finally(() => {
|
||||
_retryPromise.resolve();
|
||||
});
|
||||
} else {
|
||||
machine.stop().finally(() => {
|
||||
_retryPromise.resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
setError: function (error) {
|
||||
_error = error;
|
||||
this.emit(this.ERROR_EVENT);
|
||||
},
|
||||
pause: function () {
|
||||
_retryPromise = Promise.defer();
|
||||
|
@ -207,6 +222,7 @@ var SetupStore = assign(Object.create(EventEmitter.prototype), {
|
|||
setup: Promise.coroutine(function * () {
|
||||
while (true) {
|
||||
try {
|
||||
console.log('Starting Steps');
|
||||
var ip = yield this.run();
|
||||
if (!ip || !ip.length) {
|
||||
throw {
|
||||
|
@ -214,10 +230,13 @@ var SetupStore = assign(Object.create(EventEmitter.prototype), {
|
|||
machine: yield machine.info(),
|
||||
ip: ip,
|
||||
};
|
||||
} else {
|
||||
metrics.track('Setup Finished');
|
||||
return ip;
|
||||
}
|
||||
console.log('Finished Steps');
|
||||
console.log(ip);
|
||||
docker.setup(ip, machine.name());
|
||||
yield docker.waitForConnection();
|
||||
metrics.track('Setup Finished');
|
||||
break;
|
||||
} catch (err) {
|
||||
metrics.track('Setup Failed', {
|
||||
step: _currentStep
|
||||
|
@ -227,7 +246,7 @@ var SetupStore = assign(Object.create(EventEmitter.prototype), {
|
|||
error: err,
|
||||
step: _currentStep,
|
||||
virtualbox: virtualboxVersion
|
||||
});
|
||||
}, 'info');
|
||||
_error = err;
|
||||
this.emit(this.ERROR_EVENT);
|
||||
yield this.pause();
|
||||
|
|
|
@ -17,11 +17,11 @@ var SetupUtil = {
|
|||
return fs.statSync('/usr/local/bin').gid !== 80 || fs.statSync('/usr/local/bin').uid !== process.getuid();
|
||||
}
|
||||
|
||||
if (fs.existsSync('/usr/local/bin/docker') && (fs.statSync('/usr/local/bin/docker').gid !== 80 || fs.statSync('/usr/local/bin/docker').uid !== process.getuid())) {
|
||||
if (fs.statSync('/usr/local/bin/docker').gid !== 80 || fs.statSync('/usr/local/bin/docker').uid !== process.getuid()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (fs.existsSync('/usr/local/bin/docker-machine') && (fs.statSync('/usr/local/bin/docker-machine').gid !== 80 || fs.statSync('/usr/local/bin/docker-machine').uid !== process.getuid())) {
|
||||
if (fs.statSync('/usr/local/bin/docker-machine').gid !== 80 || fs.statSync('/usr/local/bin/docker-machine').uid !== process.getuid()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -11,7 +11,7 @@ module.exports = {
|
|||
if (code) {
|
||||
var cmd = Array.isArray(args) ? args.join(' ') : args;
|
||||
reject({
|
||||
message: cmd.replace(this.home(), '') + ' returned non zero exit code',
|
||||
message: cmd + ' returned non zero exit code',
|
||||
stderr: stderr,
|
||||
stdout: stdout
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue