Skip to content

Commit e9b2cd3

Browse files
committed
forever.logFilePath utility. Treat paths that start with / as paths relative to the root, not the forever root.
1 parent 8e323ca commit e9b2cd3

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

bin/forever

+2-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ function tryStart (callback) {
131131
options.uid = uid;
132132
options.pidFile = 'forever' + uid + '.pid';
133133
options.logFile = argv.l || 'forever' + uid + '.log';
134-
fullLog = path.join(forever.config.root, options.logFile);
134+
135+
fullLog = forever.logFilePath(options.logFile);
135136
fullScript = path.join(options.sourceDir, file);
136137

137138
forever.stat(fullLog, fullScript, function (err) {

lib/forever.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ forever.start = function (script, options) {
108108
// Starts a script with forever as a daemon
109109
//
110110
forever.startDaemon = function (script, options) {
111-
options.logFile = path.join(config.root, options.logFile || 'forever.log');
111+
options.logFile = forever.logFilePath(options.logFile);
112112
options.pidFile = path.join(config.pidPath, options.pidFile);
113113
var runner = new forever.Monitor(script, options);
114114

@@ -387,6 +387,19 @@ forever.randomString = function (bits) {
387387
return ret;
388388
};
389389

390+
//
391+
// ### function logFilePath (logFile)
392+
// #### @logFile {string} Log file path
393+
// Determines the full logfile path name
394+
//
395+
forever.logFilePath = function(logFile) {
396+
if (logFile && logFile[0] === "/") {
397+
return logFile;
398+
} else {
399+
return path.join(forever.config.root, logFile || "forever.log");
400+
}
401+
};
402+
390403
//
391404
// ### function checkProcess (pid, callback)
392405
// #### @pid {string} pid of the process to check

0 commit comments

Comments
 (0)