diff --git a/index.js b/index.js index 50d313a2..3a3d3a49 100644 --- a/index.js +++ b/index.js @@ -41,10 +41,15 @@ var start = function (callback) { // One for meteor, one for mongo freeport(function (err, webPort) { freeport(function(err, mongoPort) { - child_process.exec('kill $(ps aux -e | grep \'PURPOSE=KITEMATIC\' | awk \'{print $2}\')', function (error, stdout, stderr) { + console.log('MongoDB: ' + mongoPort); + console.log('webPort: ' + webPort); + child_process.exec('kill $(ps aux -e | grep PURPOSE=KITEMATIC | awk \'{print $2}\')', function (error, stdout, stderr) { + console.log(error); + console.log(stdout); + console.log(stderr); var mongoChild = child_process.spawn(path.join(process.cwd(), 'resources', 'mongod'), ['--bind_ip', '127.0.0.1', '--dbpath', dataPath, '--port', mongoPort, '--unixSocketPrefix', dataPath], { env: { - DB_PURPOSE: 'KITEMATIC' + PURPOSE: 'KITEMATIC' } }); var started = false; @@ -70,17 +75,6 @@ var start = function (callback) { env: user_env }); - var cleanUpChildren = function () { - console.log('Cleaning up children.') - mongoChild.kill(); - nodeChild.kill(); - }; - - process.on('exit', cleanUpChildren); - process.on('uncaughtException', cleanUpChildren); - process.on('SIGINT', cleanUpChildren); - process.on('SIGTERM', cleanUpChildren); - var opened = false; nodeChild.stdout.setEncoding('utf8'); nodeChild.stdout.on('data', function (data) { @@ -91,7 +85,7 @@ var start = function (callback) { } else { return; } - callback(rootURL); + callback(rootURL, nodeChild, mongoChild); } }); } @@ -102,7 +96,19 @@ var start = function (callback) { } }; -start(function (url) { +start(function (url, nodeChild, mongoChild) { + var cleanUpChildren = function () { + console.log('Cleaning up children.') + mongoChild.kill(); + nodeChild.kill(); + }; + if (nodeChild && mongoChild) { + process.on('exit', cleanUpChildren); + process.on('uncaughtException', cleanUpChildren); + process.on('SIGINT', cleanUpChildren); + process.on('SIGTERM', cleanUpChildren); + } + var gui = require('nw.gui'); var mainWindow = gui.Window.get(); gui.App.on('reopen', function () { @@ -117,7 +123,11 @@ start(function (url) { mainWindow.on('close', function (type) { this.hide(); if (type === 'quit') { - this.close(false); + console.log('here'); + if (nodeChild && mongoChild) { + cleanUpChildren(); + } + this.close(true); } console.log('Window Closed.'); }); diff --git a/meteor/client/views/dashboard/setup/setup-install.html b/meteor/client/views/dashboard/setup/setup-install.html index b179a4f7..a58b7c88 100644 --- a/meteor/client/views/dashboard/setup/setup-install.html +++ b/meteor/client/views/dashboard/setup/setup-install.html @@ -8,7 +8,7 @@
- {{this.imperativeMessage}} + {{this.futureMessage}}
{{/if}} {{#if $lt this.index currentInstallStep}} @@ -31,6 +31,10 @@ {{this.message}} {{#if $eq this.index failedStep}}

{{failedError}}

+ {{else}} + {{#if this.subMessage}} +

{{this.subMessage}}

+ {{/if}} {{/if}} {{/if}} diff --git a/meteor/client/views/dashboard/setup/setup-install.js b/meteor/client/views/dashboard/setup/setup-install.js index af562d2b..38ab389d 100644 --- a/meteor/client/views/dashboard/setup/setup-install.js +++ b/meteor/client/views/dashboard/setup/setup-install.js @@ -24,7 +24,7 @@ var steps = [ }, pastMessage: 'VirtualBox installed', message: 'Installing VirtualBox', - imperativeMessage: 'Install VirtualBox if necessary' + futureMessage: 'Install VirtualBox if necessary' }, // Set up the routing. @@ -36,7 +36,7 @@ var steps = [ }, pastMessage: 'Container routing set up (root required).', message: 'Setting up container routing (root required).', - imperativeMessage: 'Set up container routing to VM (root required).' + futureMessage: 'Set up container routing to VM (root required).' }, // Set up the VM for running Kitematic apps @@ -63,7 +63,7 @@ var steps = [ }, pastMessage: 'Set up the Kitematic VM', message: 'Setting up the Kitematic VM...', - imperativeMessage: 'Set up the Kitematic VM' + futureMessage: 'Set up the Kitematic VM' }, // Start the Kitematic VM @@ -74,8 +74,9 @@ var steps = [ }); }, pastMessage: 'Started the Kitematic VM', - message: 'Starting the Kitematic VM...', - imperativeMessage: 'Start the Kitematic VM' + message: 'Starting the Kitematic VM', + subMessage: '(This may take a few minutes)', + futureMessage: 'Start the Kitematic VM', }, // Set up the default Kitematic images @@ -87,7 +88,8 @@ var steps = [ }, pastMessage: 'Started the Kitematic VM', message: 'Setting up the default Kitematic images...', - imperativeMessage: 'Set up the default Kitematic images' + subMessage: '(This may take a few minutes)', + futureMessage: 'Set up the default Kitematic images', } ];