mirror of https://github.com/docker/docs.git
Merge pull request #152 from kitematic/jmorgan_fix_metrics_images
Fix metrics & hide images with <none>:<none> tag
This commit is contained in:
commit
5c98a92b4f
|
@ -31,7 +31,6 @@ AppUtil.run = function (app, callback) {
|
|||
}});
|
||||
return;
|
||||
}
|
||||
// Set a delay for app to spin up
|
||||
Apps.update(app._id, {$set: {
|
||||
docker: data,
|
||||
status: 'READY'
|
||||
|
@ -167,7 +166,7 @@ AppUtil.sync = function (callback) {
|
|||
var diffApps = _.difference(guiIds, containerIds);
|
||||
_.each(diffApps, function (appContainerId) {
|
||||
var app = Apps.findOne({'docker.Id': appContainerId});
|
||||
if (app && app.status === 'READY') {
|
||||
if (app && app.status !== 'STARTING') {
|
||||
AppUtil.remove(app._id);
|
||||
}
|
||||
});
|
||||
|
@ -180,7 +179,7 @@ AppUtil.sync = function (callback) {
|
|||
return app.status === 'STARTING' && app.name === appName;
|
||||
});
|
||||
|
||||
if (startingApp || _.isEmpty(container.NetworkSettings.Ports)) {
|
||||
if (startingApp || _.isEmpty(container.NetworkSettings.Ports) || !_.pairs(container.NetworkSettings.Ports)[0][1]) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,8 +109,6 @@ Docker.runContainer = function (app, image, callback) {
|
|||
containerOpts.ExposedPorts = app.docker.NetworkSettings.Ports;
|
||||
}
|
||||
|
||||
console.log(containerOpts);
|
||||
|
||||
Docker.client().createContainer(containerOpts, function (err, container) {
|
||||
if (err) { callback(err, null); return; }
|
||||
console.log('Created container: ' + container.id);
|
||||
|
@ -135,7 +133,6 @@ Docker.runContainer = function (app, image, callback) {
|
|||
startOpts.PublishAllPorts = true;
|
||||
}
|
||||
|
||||
console.log(startOpts);
|
||||
container.start(startOpts, function (err) {
|
||||
if (err) { callback(err, null); return; }
|
||||
console.log('Started container: ' + container.id);
|
||||
|
|
|
@ -259,7 +259,7 @@ ImageUtil.sync = function (callback) {
|
|||
var diffImages = _.difference(kitematicIds, daemonIds);
|
||||
_.each(diffImages, function (imageId) {
|
||||
var image = Images.findOne({'docker.Id': imageId});
|
||||
if (image && image.status === 'READY') {
|
||||
if (image && image.status !== 'BUILDING') {
|
||||
Images.remove(image._id);
|
||||
}
|
||||
});
|
||||
|
@ -269,7 +269,7 @@ ImageUtil.sync = function (callback) {
|
|||
return _.contains(kitematicIds, image.Id);
|
||||
});
|
||||
_.each(diffDockerImages, function (image) {
|
||||
if (!image.RepoTags || !image.Config || _.isEmpty(image.Config.ExposedPorts)) {
|
||||
if (!image.RepoTags || !image.RepoTags || image.RepoTags[0] === '<none>:<none>' || !image.Config || _.isEmpty(image.Config.ExposedPorts)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,11 @@ var remote = require('remote');
|
|||
var app = remote.require('app');
|
||||
var crypto = require('crypto');
|
||||
var uuid = require('node-uuid');
|
||||
var level = require('levelup');
|
||||
var path = require('path');
|
||||
var db = level(path.join(process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'], 'Library/Application Support/Kitematic/data', 'db'));
|
||||
var fs = require('fs');
|
||||
|
||||
var level = require('levelup');
|
||||
var db;
|
||||
|
||||
Metrics = {};
|
||||
|
||||
|
@ -49,20 +51,34 @@ Metrics.trackEvent = function (name) {
|
|||
});
|
||||
};
|
||||
|
||||
Metrics.prepareTracking = function () {
|
||||
Metrics.prepareUUID = function (callback) {
|
||||
db.get('metrics.uuid', function (err, value) {
|
||||
if (err && err.notFound) {
|
||||
db.put('metrics.uuid', uuid.v4(), function (err) {
|
||||
callback();
|
||||
});
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Metrics.prepareTracking = function (callback) {
|
||||
db = level(Util.getMetricsDir());
|
||||
db.get('metrics.enabled', function (err, value) {
|
||||
if (err && err.notFound) {
|
||||
var settings = Settings.findOne();
|
||||
if (settings && settings.tracking) {
|
||||
db.put('metrics.enabled', !!settings.tracking);
|
||||
db.put('metrics.enabled', !!settings.tracking, function(err) {
|
||||
Metrics.prepareUUID(callback);
|
||||
});
|
||||
} else {
|
||||
db.put('metrics.enabled', true);
|
||||
db.put('metrics.enabled', true, function (err) {
|
||||
Metrics.prepareUUID(callback);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Metrics.prepareUUID(callback);
|
||||
}
|
||||
db.get('metrics.uuid', function (err, value) {
|
||||
if (err && err.notFound) {
|
||||
db.put('metrics.uuid', uuid.v4());
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -2,28 +2,20 @@ var fs = require('fs');
|
|||
|
||||
Meteor.startup(function () {
|
||||
console.log('Kitematic started.');
|
||||
if (!fs.existsSync(Util.KITE_PATH)) {
|
||||
console.log('Created Kitematic directory.');
|
||||
fs.mkdirSync(Util.KITE_PATH);
|
||||
}
|
||||
if (!fs.existsSync(Util.KITE_TAR_PATH)) {
|
||||
console.log('Created Kitematic .tar directory.');
|
||||
fs.mkdirSync(Util.KITE_TAR_PATH);
|
||||
}
|
||||
if (!fs.existsSync(Util.KITE_IMAGES_PATH)) {
|
||||
console.log('Created Kitematic .images directory.');
|
||||
fs.mkdirSync(Util.KITE_IMAGES_PATH);
|
||||
}
|
||||
if (!fs.existsSync(Util.getResourceDir())) {
|
||||
fs.mkdirSync(Util.getResourceDir());
|
||||
}
|
||||
|
||||
Metrics.prepareTracking();
|
||||
Metrics.trackEvent('app started');
|
||||
Metrics.trackEvent('app heartbeat');
|
||||
Meteor.setInterval(function () {
|
||||
[Util.KITE_PATH, Util.KITE_TAR_PATH, Util.KITE_IMAGES_PATH, Util.getAppSupportDir(), Util.getResourceDir(), Util.getDataDir(), Util.getMetricsDir()].forEach(function (d) {
|
||||
if (!fs.existsSync(d)) {
|
||||
fs.mkdirSync(d);
|
||||
}
|
||||
});
|
||||
|
||||
Metrics.prepareTracking(function() {
|
||||
Metrics.trackEvent('app started');
|
||||
Metrics.trackEvent('app heartbeat');
|
||||
}, 14400000);
|
||||
Meteor.setInterval(function () {
|
||||
Metrics.trackEvent('app heartbeat');
|
||||
}, 14400000);
|
||||
});
|
||||
|
||||
Boot2Docker.ip(function (err, ip) {
|
||||
if (!err) {
|
||||
|
|
|
@ -17,6 +17,10 @@ Util.getBinDir = function () {
|
|||
return path.join(process.env.DIR, 'resources');
|
||||
};
|
||||
|
||||
Util.getAppSupportDir = function () {
|
||||
return path.join(Util.getHomePath(), 'Library/Application Support/Kitematic');
|
||||
};
|
||||
|
||||
Util.getResourceDir = function () {
|
||||
return path.join(Util.getHomePath(), 'Library/Application Support/Kitematic/Resources');
|
||||
};
|
||||
|
@ -25,6 +29,10 @@ Util.getDataDir = function () {
|
|||
return path.join(Util.getHomePath(), 'Library/Application Support/Kitematic/data');
|
||||
};
|
||||
|
||||
Util.getMetricsDir = function () {
|
||||
return path.join(Util.getHomePath(), 'Library/Application Support/Kitematic/data/db');
|
||||
};
|
||||
|
||||
Util.KITE_PATH = path.join(Util.getHomePath(), 'Kitematic');
|
||||
Util.KITE_TAR_PATH = path.join(Util.KITE_PATH, '.tar');
|
||||
Util.KITE_IMAGES_PATH = path.join(Util.KITE_PATH, '.images');
|
||||
|
|
|
@ -225,7 +225,7 @@ updateBoot2DockerUtilization = function (callback) {
|
|||
|
||||
startUpdatingBoot2DockerUtilization = function () {
|
||||
updateBoot2DockerUtilization(function (err) { if (err) {console.log(err);} });
|
||||
Meteor.setTimeout(startUpdatingBoot2DockerUtilization, 2000);
|
||||
Meteor.setTimeout(startUpdatingBoot2DockerUtilization, 8000);
|
||||
};
|
||||
|
||||
startSyncingAppState = function () {
|
||||
|
@ -239,5 +239,5 @@ startSyncingAppState = function () {
|
|||
}
|
||||
});
|
||||
});
|
||||
Meteor.setTimeout(startSyncingAppState, 2000);
|
||||
Meteor.setTimeout(startSyncingAppState, 8000);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Kitematic",
|
||||
"version": "0.4.3",
|
||||
"version": "0.4.4",
|
||||
"author": "Kitematic",
|
||||
"description": "Simple Docker App management for Mac OS X.",
|
||||
"homepage": "https://kitematic.com/",
|
||||
|
|
Loading…
Reference in New Issue