Permalink
Browse files

Added retry logic on file parse to reduce read/write collisions

  • Loading branch information...
1 parent ae23b57 commit 8814f0366d769292cff7272d995fcda3dc0d99fe Loren West committed Jun 1, 2012
Showing with 8 additions and 1 deletion.
  1. +1 −0 History.md
  2. +7 −1 lib/config.js
View
@@ -3,6 +3,7 @@
* Added the local.EXT and local-deployment.EXT configs.
* Removed unnecessary debug output
+ * Added retry logic on file parse to reduce read/write collisions
0.4.13 / 2012-04-25
===================
View
@@ -434,7 +434,7 @@ Config.prototype.watchForConfigFileChanges = function(interval) {
if (interval === 0) {return;}
// Re-merge the runtime JSON file if we notice a change
- var onFileChange = function() {
+ var onFileChange = function(retry) {
FileSystem.readFile(runtimeJsonFilename, 'UTF-8', function(err, fileContent) {
// Not much to do on error
@@ -450,6 +450,12 @@ Config.prototype.watchForConfigFileChanges = function(interval) {
t._extendDeep(t, configObject);
} catch (e) {
console.error("Error parsing " + runtimeJsonFilename, e);
+ // Retry once - could be someone else writing
+ if (!retry) {
+ setTimeout(function(){
+ onFileChange(true);
+ }, 1000);
+ }
return;
}
});

0 comments on commit 8814f03

Please sign in to comment.