git2consul
Advanced tools
Comparing version 0.6.0 to 0.6.1
var fs = require('fs'); | ||
var path = require('path'); | ||
var mkdirp = require('mkdirp'); | ||
var rimraf = require('rimraf'); | ||
@@ -10,2 +11,9 @@ var logger = require('./utils/logging.js'); | ||
exports.purgeBranchCache = function(repo_config, branch, cb) { | ||
var branch_parent = repo_config.local_store + path.sep + repo_config.name; | ||
var branch_directory = branch_parent + path.sep + branch; | ||
rimraf(branch_directory, cb); | ||
}; | ||
exports.manageBranch = function(repo_config, branch, branch_creation_callback) { | ||
@@ -144,4 +152,4 @@ | ||
// Check to see if the branch_parent is already present. | ||
fs.stat(branch_parent, function(err, stat) { | ||
// Check to see if the branch directory is already present. | ||
fs.stat(branch_directory, function(err, stat) { | ||
if (stat) { | ||
@@ -165,3 +173,3 @@ // This branch was already cloned. Do a pull to make sure it's up to date. | ||
// Create the branch_parent_directory and clone the branch from there. | ||
// Create the branch_parent_directory (if necessary) and clone the branch from there. | ||
mkdirp(branch_parent, function(err) { | ||
@@ -168,0 +176,0 @@ /* istanbul ignore next */ |
@@ -111,3 +111,9 @@ var _ = require('underscore'); | ||
branch_manager.manageBranch(repo_config, branch, function(err, bm) { | ||
if (err) return cb('Failed to create manager for branch ' + branch + ': ' + err); | ||
if (err) { | ||
// The most common reason for this to fail is due to a failed clone or otherwise corrupted git cache. Try | ||
// killing the branch dir before failing so that the next start will have a clean slate. | ||
return branch_manager.purgeBranchCache(repo_config, branch, function() { | ||
cb('Failed to create manager for branch ' + branch + ': ' + err); | ||
}); | ||
} | ||
@@ -114,0 +120,0 @@ ++branch_count; |
{ | ||
"name": "git2consul", | ||
"description": "System for moving data from git to consul", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"contributors": [ | ||
@@ -17,2 +17,3 @@ { | ||
"mkdirp": "0.5.0", | ||
"rimraf": "2.2.8", | ||
"underscore": "1.6.0" | ||
@@ -24,3 +25,2 @@ }, | ||
"request": "^2.42.0", | ||
"rimraf": "2.2.8", | ||
"should": "3.3.2", | ||
@@ -27,0 +27,0 @@ "xunit-file": "0.0.5" |
@@ -74,3 +74,3 @@ #### git2consul | ||
If you would like git2consul to shutdown every time its configuration changes, you can enable halt-on-change mode wit the command-line switch `-h` or inclusion of the field `"halt_on_change": true` at the top level of your config JSON. If this mode is enabled, git2consul will wait for changes in the config (which is itself stored in Consul) and gracefully halt when a change is detected. It is expected that your git2consul process is configured to run as a service, so restarting git2consul is the responsibility of your service manager. | ||
If you would like git2consul to shutdown every time its configuration changes, you can enable halt-on-change mode with the command-line switch `-h` or inclusion of the field `"halt_on_change": true` at the top level of your config JSON. If this mode is enabled, git2consul will wait for changes in the config (which is itself stored in Consul) and gracefully halt when a change is detected. It is expected that your git2consul process is configured to run as a service, so restarting git2consul is the responsibility of your service manager. | ||
@@ -77,0 +77,0 @@ ##### How it works |
88289
5
1930
7
+ Addedrimraf@2.2.8
+ Addedrimraf@2.2.8(transitive)