Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Commit

Permalink
Merge branch 'rc'
Browse files Browse the repository at this point in the history
  • Loading branch information
seanli committed Sep 4, 2014
2 parents c300950 + 9e1162e commit 2911986
Show file tree
Hide file tree
Showing 42 changed files with 825 additions and 1,102 deletions.
5 changes: 1 addition & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ var start = function (callback) {
});
var started = false;
mongoChild.stdout.setEncoding('utf8');
mongoChild.stderr.setEncoding('utf8');
mongoChild.stderr.on('data', function (data) {
console.log(data);
});
mongoChild.stdout.on('data', function (data) {
console.log(data);
if (data.indexOf('waiting for connections on port ' + mongoPort)) {
Expand Down Expand Up @@ -124,6 +120,7 @@ start(function (url, nodeChild, mongoChild) {
}, 400);
mainWindow.on('close', function (type) {
this.hide();
console.log('closed');
if (type === 'quit') {
console.log('here');
if (nodeChild && mongoChild) {
Expand Down
65 changes: 8 additions & 57 deletions meteor/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,6 @@
"convert": true,
"Convert": true,

// Collections
"SimpleSchema": false,
"ServiceConfiguration": false,
"Apps": true,
"schemaApps": true,
"Images": true,
"schemaImages": true,
"Installs": true,
"schemaInstalls": true,

// Controllers
"RouteController": true,
"DashboardController": true,
Expand All @@ -164,51 +154,17 @@
"SetupController": true,

// Server and Client
"Images": true,
"Apps": true,
"Installs": true,
"Docker": true,
"Util": true,
"Sync": true,
"Boot2Docker": true,
"Installer": true,
"VirtualBox": true,

"boot2dockerexec": true,
"getBoot2DockerIp": true,
"getBoot2DockerState": true,
"getBoot2DockerDiskUsage": true,
"getBoot2DockerMemoryUsage": true,
"getBoot2DockerInfo": true,
"boot2DockerVMExists": true,
"eraseBoot2DockerVMFiles": true,
"initBoot2Docker": true,
"isVirtualBoxInstalled": true,
"upgradeBoot2Docker": true,
"installBoot2DockerAddons": true,
"startBoot2Docker": true,
"stopBoot2Docker": true,
"checkBoot2DockerVM": true,
"resolveBoot2DockerVM": true,
"startFixInterval": true,
"trackLink": true,
"isResolverSetup": true,
"setupVirtualBoxAndResolver": true,
"setupVirtualBoxSharedFolder": true,
"updateBoot2DockerInfo": true,
"fixBoot2DockerVM": true,
"fixDefaultImages": true,
"fixDefaultContainers": true,
"fixInterval": true,
"stopFixInterval": true,
"runSetup": true,
"removeAppWatcher": true,
"addAppWatcher": true,
"resolveWatchers": true,
"checkDefaultImages": true,
"resolveDefaultImages": true,
"checkDefaultContainers": true,
"resolveDefaultContainers": true,
"killAndRemoveContainers": true,
"upContainers": true,
"reloadDefaultContainers": true,
"removeImages": true,
"ImageUtil": true,
"AppUtil": true,

// Forms
"showFormErrors": true,
Expand All @@ -217,18 +173,13 @@
"FormSchema": true,
"showFormSuccess": true,
"resetForm": true,
"trackLink": true,

// Testing
"require": false,
"suite": false,
"test": false,
"emit": false,

// Constants
"KITE_PATH": true,
"KITE_TAR_PATH": true,
"KITE_IMAGES_PATH": true,
"COMMON_WEB_PORTS": true
"emit": false

}
}
5 changes: 0 additions & 5 deletions meteor/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
standard-app-packages
less
bootstrap3-less
npm
iron-router
headers
handlebar-helpers
collection2
collection-hooks
moment
underscore-string-latest
collection-helpers
octicons
Expand Down
127 changes: 127 additions & 0 deletions meteor/client/lib/apputil.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
var exec = require('exec');
var path = require('path');
var Convert = require('ansi-to-html');
var convert = new Convert();

AppUtil = {};

AppUtil.run = function (app) {
var image = Images.findOne({_id: app.imageId});
// Delete old container if one already exists
Docker.removeContainer(app.name, function (err) {
if (err) { console.error(err); }
Docker.runContainer(app, image, function (err, container) {
if (err) { throw err; }
Docker.getContainerData(container.id, function (err, data) {
if (err) { console.error(err); }
// Set a delay for app to spin up
Meteor.setTimeout(function () {
Apps.update(app._id, {$set: {
docker: data,
status: 'READY'
}});
}, 2500);
});
});
});
};

AppUtil.restartHelper = function (app) {
if (app.docker && app.docker.Id) {
Docker.restartContainer(app.docker.Id, function (err) {
if (err) { console.error(err); }
Docker.getContainerData(app.docker.Id, function (err, data) {
if (err) { console.error(err); }
// Use dig to refresh the DNS
exec('/usr/bin/dig ' + app.name + '.kite @172.17.42.1', function(err, stdout, stderr) {
console.log(err);
console.log(stdout);
console.log(stderr);
Apps.update(app._id, {$set: {
status: 'READY',
docker: data
}});
});
});
});
}
};

AppUtil.restart = function (appId) {
var app = Apps.findOne(appId);
if (app && app.docker) {
Apps.update(app._id, {$set: {
status: 'STARTING'
}});
AppUtil.restartHelper(app);
}
};

AppUtil.remove = function (appId) {
var app = Apps.findOne(appId);
if (app.docker) {
Apps.remove({_id: appId});
Docker.removeContainer(app.docker.Id, function (err) {
if (err) { console.error(err); }
var appPath = path.join(Util.KITE_PATH, app.name);
Util.deleteFolder(appPath);
Docker.removeBindFolder(app.name, function () {
console.log('Deleted Kite ' + app.name + ' directory.');
});
});
}
};

AppUtil.configVar = function (appId, configVars) {
Apps.update(appId, {$set: {
config: configVars,
status: 'STARTING'
}});
var app = Apps.findOne({_id: appId});
AppUtil.run(app);
};

AppUtil.logs = function (appId) {
var app = Apps.findOne(appId);
if (app.docker && app.docker.Id) {
var container = Docker.client().getContainer(app.docker.Id);
container.logs({follow: false, stdout: true, stderr: true, timestamps: false, tail: 300}, function (err, response) {
if (err) { throw err; }
Apps.update(app._id, {
$set: {
logs: []
}
});
var logs = [];
response.setEncoding('utf8');
response.on('data', function (line) {
Apps.update(app._id, {
$push: {
logs: convert.toHtml(line.slice(8))
}
});
});
response.on('end', function () {});
});
}
};

AppUtil.recover = function () {
var apps = Apps.find({}).fetch();
_.each(apps, function (app) {
// Update the app with the latest container info
if (!app.docker) {
return;
}
var container = Docker.client().getContainer(app.docker.Id);
container.inspect(function (err, data) {
if (app.status !== 'STARTING' && data && data.State && !data.State.Running) {
console.log('Restarting: ' + app.name);
console.log(app.docker.Id);
AppUtil.restartHelper(app, function (err) {
if (err) { console.error(err); }
});
}
});
});
};
12 changes: 7 additions & 5 deletions meteor/client/lib/boot2docker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var exec = require('exec');
var path = require('path');
var fs = require('fs');

Boot2Docker = {};

Expand All @@ -23,11 +24,8 @@ Boot2Docker.exists = function (callback) {

Boot2Docker.stop = function (callback) {
this.exec('stop', function (err, stdout) {
if (err) {
callback(err);
} else {
callback(null);
}
// Sometimes stop returns an error even though it worked
callback(null);
});
};

Expand Down Expand Up @@ -202,6 +200,10 @@ Boot2Docker.stats = function (callback) {
});
};

Boot2Docker.sshKeyExists = function () {
return fs.existsSync(path.join(Util.getHomePath(), '.ssh', 'id_boot2docker'));
};

/**
* Get the VM's version.
* Node that this only works if the VM is up and running.
Expand Down

0 comments on commit 2911986

Please sign in to comment.