Fixing installer & mongodb startup bug.

This commit is contained in:
Jeff Morgan 2014-08-29 10:49:26 -07:00
Родитель 548d8f33ba
Коммит 6a6f21fa51
3 изменённых файлов: 39 добавлений и 23 удалений

Просмотреть файл

@ -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.');
});

Просмотреть файл

@ -8,7 +8,7 @@
<img src="/step_pending.png">
</span>
<div class="media-body">
{{this.imperativeMessage}}
{{this.futureMessage}}
</div>
{{/if}}
{{#if $lt this.index currentInstallStep}}
@ -31,6 +31,10 @@
{{this.message}}
{{#if $eq this.index failedStep}}
<p>{{failedError}}</p>
{{else}}
{{#if this.subMessage}}
<p>{{this.subMessage}}</p>
{{/if}}
{{/if}}
</div>
{{/if}}

Просмотреть файл

@ -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',
}
];