Skip to content

Commit 8186994

Browse files
committed
[fix] Alter logging paths to reduce memory leakage and prevent stdio issues.
1 parent 5c8fcc5 commit 8186994

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

lib/forever.js

+6
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,12 @@ forever.stat = function (logFile, script, callback) {
353353
// Starts a script with forever
354354
//
355355
forever.start = function (script, options) {
356+
if (!options.uid) {
357+
options.uid = options.uid || utile.randomString(4).replace(/^\-/, '_');
358+
}
359+
if (!options.logFile) {
360+
options.logFile = forever.logFilePath(options.uid + '.log');
361+
}
356362
return new forever.Monitor(script, options).start();
357363
};
358364

lib/forever/monitor.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ var Monitor = exports.Monitor = function (script, options) {
3131
// can be attached through `monitor.use(plugin, options)`.
3232
//
3333
function bootstrap(monitor) {
34-
forever.plugins.logger.attach.call(monitor, options);
3534

3635
if (options.watch) {
3736
forever.plugins.watch.attach.call(monitor, options);
@@ -53,22 +52,14 @@ var Monitor = exports.Monitor = function (script, options) {
5352
this.childExists = false;
5453
this.checkFile = options.checkFile !== false;
5554
this.times = 0;
55+
this.daemon = options.daemon || false;
5656

5757
//
5858
// Setup log files and logger for this instance.
5959
//
6060
this.logFile = options.logFile || path.join(forever.config.get('root'), this.uid + '.log');
6161
this.outFile = options.outFile;
6262
this.errFile = options.errFile;
63-
this.logger = options.logger || new (winston.Logger)({
64-
transports: [new winston.transports.Console({ silent: this.silent })]
65-
});
66-
67-
//
68-
// Extend from the winston logger.
69-
//
70-
this.logger.extend(this);
71-
this.log = fs.createWriteStream(this.logFile, { flags: 'a+', encoding: 'utf8', mode: '0666' });
7263

7364
//
7465
// Setup restart timing. These options control how quickly forever restarts
@@ -153,6 +144,11 @@ Monitor.prototype.start = function (restart) {
153144
return this;
154145
}
155146

147+
if (!this.silent) {
148+
child.stdout.pipe(process.stdout);
149+
child.stderr.pipe(process.stderr);
150+
}
151+
156152
this.ctime = Date.now();
157153
this.child = child;
158154
this.running = true;

0 commit comments

Comments
 (0)