Permalink
Browse files

Fix #16 - Remove the fs.exists check for handling USR2 signals

When running multiple processes that are writing to the same log
(not clustered), there is a race condition where the first process
to handle the signal will reopen the file handle (creating the
file), and all other processes will ignore the request because the
file already exists.  This fixes that issue.
  • Loading branch information...
1 parent bb1e8b5 commit e8124636e6dd88e69aac8a1f5fae39e7c61d5470 Matthew Ratzloff committed Oct 9, 2012
Showing with 1 addition and 5 deletions.
  1. +1 −5 lib/log4node.js
View
@@ -69,11 +69,7 @@ function Log4Node(config) {
this.file = config.file;
this.reopen();
sig_listener.on('SIGUSR2', function() {
- fs.exists(this.file, function(exists) {
- if (!exists) {
- this.reopen();
- }
- }.bind(this));
+ this.reopen();
}.bind(this));
this.stream.on('error', function(err) {
console.warn('Unable to write into file : ' + this.file + ' ' + err);

0 comments on commit e812463

Please sign in to comment.