diff --git a/src/components/Header.react.js b/src/components/Header.react.js index e69c14ea80..d56ec9a7b8 100644 --- a/src/components/Header.react.js +++ b/src/components/Header.react.js @@ -2,7 +2,6 @@ import React from 'react/addons'; import remote from 'remote'; import RetinaImage from 'react-retina-image'; import ipc from 'ipc'; -var autoUpdater = remote.require('auto-updater'); import util from '../utils/Util'; import metrics from '../utils/MetricsUtil'; var Menu = remote.require('menu'); @@ -32,7 +31,6 @@ var Header = React.createClass({ updateAvailable: true }); }); - autoUpdater.checkForUpdates(); }, componentWillUnmount: function () { document.removeEventListener('keyup', this.handleDocumentKeyUp, false); diff --git a/src/utils/DockerMachineUtil.js b/src/utils/DockerMachineUtil.js index fa22e37eab..d3d462ecbc 100644 --- a/src/utils/DockerMachineUtil.js +++ b/src/utils/DockerMachineUtil.js @@ -22,7 +22,7 @@ var DockerMachine = { return fs.existsSync(this.command()); }, version: function () { - return util.exec([this.command(), '-v']).then(stdout => { + return util.execFile([this.command(), '-v']).then(stdout => { try { var matchlist = stdout.match(/(\d+\.\d+\.\d+).*/); if (!matchlist || matchlist.length < 2) { @@ -57,40 +57,40 @@ var DockerMachine = { }); }, create: function (machineName = this.name()) { - return util.exec([this.command(), '-D', 'create', '-d', 'virtualbox', '--virtualbox-memory', '2048', machineName]); + return util.execFile([this.command(), '-D', 'create', '-d', 'virtualbox', '--virtualbox-memory', '2048', machineName]); }, start: function (machineName = this.name()) { - return util.exec([this.command(), '-D', 'start', machineName]); + return util.execFile([this.command(), '-D', 'start', machineName]); }, stop: function (machineName = this.name()) { - return util.exec([this.command(), 'stop', machineName]); + return util.execFile([this.command(), 'stop', machineName]); }, upgrade: function (machineName = this.name()) { - return util.exec([this.command(), 'upgrade', machineName]); + return util.execFile([this.command(), 'upgrade', machineName]); }, rm: function (machineName = this.name()) { - return util.exec([this.command(), 'rm', '-f', machineName]); + return util.execFile([this.command(), 'rm', '-f', machineName]); }, ip: function (machineName = this.name()) { - return util.exec([this.command(), 'ip', machineName]).then(stdout => { + return util.execFile([this.command(), 'ip', machineName]).then(stdout => { return Promise.resolve(stdout.trim().replace('\n', '')); }); }, url: function (machineName = this.name()) { - return util.exec([this.command(), 'url', machineName]).then(stdout => { + return util.execFile([this.command(), 'url', machineName]).then(stdout => { return Promise.resolve(stdout.trim().replace('\n', '')); }); }, regenerateCerts: function (machineName = this.name()) { - return util.exec([this.command(), 'tls-regenerate-certs', '-f', machineName]); + return util.execFile([this.command(), 'tls-regenerate-certs', '-f', machineName]); }, status: function (machineName = this.name()) { - return util.exec([this.command(), 'status', machineName]).then(stdout => { + return util.execFile([this.command(), 'status', machineName]).then(stdout => { return Promise.resolve(stdout.trim().replace('\n', '')); }); }, disk: function (machineName = this.name()) { - return util.exec([this.command(), 'ssh', machineName, 'df']).then(stdout => { + return util.execFile([this.command(), 'ssh', machineName, 'df']).then(stdout => { try { var lines = stdout.split('\n'); var dataline = _.find(lines, function (line) { @@ -114,7 +114,7 @@ var DockerMachine = { }); }, memory: function (machineName = this.name()) { - return util.exec([this.command(), 'ssh', machineName, 'free -m']).then(stdout => { + return util.execFile([this.command(), 'ssh', machineName, 'free -m']).then(stdout => { try { var lines = stdout.split('\n'); var dataline = _.find(lines, function (line) { @@ -155,11 +155,11 @@ var DockerMachine = { cmd = cmd || process.env.SHELL; var terminal = util.linuxTerminal(); if (terminal) - util.exec(terminal.concat([cmd])).then(() => {}); + util.execFile(terminal.concat([cmd])).then(() => {}); } else { cmd = cmd || process.env.SHELL; this.url(machineName).then(machineUrl => { - util.exec([path.join(process.env.RESOURCES_PATH, 'terminal'), `DOCKER_HOST=${machineUrl} DOCKER_CERT_PATH=${path.join(util.home(), '.docker/machine/machines/' + machineName)} DOCKER_TLS_VERIFY=1 ${cmd}`]).then(() => {}); + util.execFile([path.join(process.env.RESOURCES_PATH, 'terminal'), `DOCKER_HOST=${machineUrl} DOCKER_CERT_PATH=${path.join(util.home(), '.docker/machine/machines/' + machineName)} DOCKER_TLS_VERIFY=1 ${cmd}`]).then(() => {}); }); } }, diff --git a/src/utils/SetupUtil.js b/src/utils/SetupUtil.js index e2b794851a..c1d09ad5e2 100644 --- a/src/utils/SetupUtil.js +++ b/src/utils/SetupUtil.js @@ -137,9 +137,9 @@ export default { let tries = 80, ip = null; while (!ip && tries > 0) { try { + tries -= 1; console.log('Trying to fetch machine IP, tries left: ' + tries); ip = await machine.ip(); - tries -= 1; await Promise.delay(1000); } catch (err) {} } @@ -153,11 +153,12 @@ export default { break; } catch (error) { router.get().transitionTo('setup'); - metrics.track('Setup Failed', { + + let novtx = error.message.indexOf('This computer doesn\'t have VT-X/AMD-v enabled') !== -1; + metrics.track(novtx ? 'Setup Halted' : 'Setup Failed', { virtualBoxVersion, machineVersion }); - setupServerActions.error({error}); let message = error.message.split('\n'); let lastLine = message.length > 1 ? message[message.length - 2] : 'Docker Machine encountered an error.'; @@ -170,6 +171,8 @@ export default { groupingHash: machineVersion }, 'info'); + setupServerActions.error({error: new Error(lastLine)}); + this.clearTimers(); await this.pause(); } diff --git a/src/utils/Util.js b/src/utils/Util.js index 4add73aa43..995e547f33 100644 --- a/src/utils/Util.js +++ b/src/utils/Util.js @@ -8,20 +8,20 @@ var dialog = remote.require('dialog'); var app = remote.require('app'); module.exports = { - exec: function (args, options) { - options = options || {}; - - // Add resources dir to exec path for Windows - if (this.isWindows()) { - options.env = options.env || {}; - if (!options.env.PATH) { - options.env.PATH = process.env.RESOURCES_PATH + ';' + process.env.PATH; - } - } - + execFile: function (args, options) { return new Promise((resolve, reject) => { - var cmd = Array.isArray(args) ? args.join(' ') : args; - child_process.exec(cmd, options, (error, stdout, stderr) => { + child_process.execFile(args[0], args.slice(1), options, (error, stdout, stderr) => { + if (error) { + reject(new Error('Encountered an error: ' + error)); + } else { + resolve(stdout); + } + }); + }); + }, + exec: function (args, options) { + return new Promise((resolve, reject) => { + child_process.exec(args, options, (error, stdout, stderr) => { if (error) { reject(new Error('Encountered an error: ' + error)); } else { diff --git a/src/utils/VirtualBoxUtil.js b/src/utils/VirtualBoxUtil.js index 2768eecc11..1d9bae104f 100644 --- a/src/utils/VirtualBoxUtil.js +++ b/src/utils/VirtualBoxUtil.js @@ -16,13 +16,16 @@ var VirtualBox = { } }, installed: function () { + if (util.isWindows() && !process.env.VBOX_INSTALL_PATH && !process.env.VBOX_MSI_INSTALL_PATH) { + return false; + } return fs.existsSync(this.command()); }, active: function () { return fs.existsSync('/dev/vboxnetctl'); }, version: function () { - return util.exec([this.command(), '-v']).then(stdout => { + return util.execFile([this.command(), '-v']).then(stdout => { let matchlist = stdout.match(/(\d+\.\d+\.\d+).*/); if (!matchlist || matchlist.length < 2) { Promise.reject('VBoxManage -v output format not recognized.'); @@ -32,29 +35,11 @@ var VirtualBox = { return Promise.resolve(null); }); }, - poweroffall: function () { - return util.exec(this.command() + ' list runningvms | sed -E \'s/.*\\{(.*)\\}/\\1/\' | xargs -L1 -I {} ' + this.command() + ' controlvm {} poweroff'); - }, mountSharedDir: function (vmName, pathName, hostPath) { - return util.exec([this.command(), 'sharedfolder', 'add', vmName, '--name', pathName, '--hostpath', hostPath, '--automount']); - }, - killall: function () { - if (util.isWindows()) { - return this.poweroffall().then(() => { - return util.exec(['powershell.exe', '\"get-process VBox* | stop-process\"']); - }).catch(() => {}); - } else { - return this.poweroffall().then(() => { - return util.exec(['pkill', 'VirtualBox']); - }).then(() => { - return util.exec(['pkill', 'VBox']); - }).catch(() => { - - }); - } + return util.execFile([this.command(), 'sharedfolder', 'add', vmName, '--name', pathName, '--hostpath', hostPath, '--automount']); }, vmExists: function (name) { - return util.exec([this.command(), 'showvminfo', name]).then(() => { + return util.execFile([this.command(), 'showvminfo', name]).then(() => { return true; }).catch((err) => { return false;