最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Node.js Forever is not creating Log files - Stack Overflow

programmeradmin4浏览0评论

2 nodejs scripts are being handled by forever. The system is using forever v0.11.1 and node v0.10.29

# forever list
info:    Forever processes running
data:        uid  mand  script      forever pid   logfile                 uptime        
data:    [0] D34J userdown app/main.js 7441    10950 /root/.forever/D34J.log 0:2:31:45.572 
data:    [1] P0BX userdown app/main.js 11242   11261 /root/.forever/P0BX.log 0:2:20:22.157 
# forever logs 0
error:   undefined
# forever logs 1
error:   undefined

Question: Why are the log files created by forever missing? Restarting the 2 processes still doesn't create any log files...

The directory /root/.forever does not show the log files too!

# ls -la /root/.forever
total 20
drwxr-xr-x 4 root root 4096 Jul  4 11:37 .
drwx------ 8 root root 4096 Jul 10 13:24 ..
-rw-r--r-- 1 root root  259 Jul 10 19:34 config.json
drwxr-xr-x 2 root root 4096 Jul  4 11:37 pids
drwxr-xr-x 2 root root 4096 Jul 10 17:12 sock

2 nodejs scripts are being handled by forever. The system is using forever v0.11.1 and node v0.10.29

# forever list
info:    Forever processes running
data:        uid  mand  script      forever pid   logfile                 uptime        
data:    [0] D34J userdown app/main.js 7441    10950 /root/.forever/D34J.log 0:2:31:45.572 
data:    [1] P0BX userdown app/main.js 11242   11261 /root/.forever/P0BX.log 0:2:20:22.157 
# forever logs 0
error:   undefined
# forever logs 1
error:   undefined

Question: Why are the log files created by forever missing? Restarting the 2 processes still doesn't create any log files...

The directory /root/.forever does not show the log files too!

# ls -la /root/.forever
total 20
drwxr-xr-x 4 root root 4096 Jul  4 11:37 .
drwx------ 8 root root 4096 Jul 10 13:24 ..
-rw-r--r-- 1 root root  259 Jul 10 19:34 config.json
drwxr-xr-x 2 root root 4096 Jul  4 11:37 pids
drwxr-xr-x 2 root root 4096 Jul 10 17:12 sock
Share Improve this question asked Jul 10, 2014 at 23:37 NyxynyxNyxynyx 63.7k163 gold badges506 silver badges855 bronze badges 1
  • 1 What mand are you using to launch forever? And what operating system are you using? – ctlacko Commented Jul 11, 2014 at 1:27
Add a ment  | 

3 Answers 3

Reset to default 6

If you start your node process with forever your_script.js and don't specify a log file, forever will write your logs to the terminal (or cmd on Windows). The log file that is shown when you run forever list or forever logs does not reflect reality, since it's not created in that scenario. But if you specify log files, following the options:

-l  LOGFILE      Logs the forever output to LOGFILE
-o  OUTFILE      Logs stdout from child script to OUTFILE
-e  ERRFILE      Logs stderr from child script to ERRFILE

, like forever -l console.log -e error.log your_script.log, they will be created.

If you want forever to automatically create a log file for you, you have to start your script as a daemon, with forever start your_script.js. In this case, you can also specify your log files.

In the docs page you can see all the mand line options.

To answer Shreejibawa (since I can't ment yet)...

forever is very sensitive to the order of the arguments. Take a look at their documentation and notice that the options must e before the script.

forever [action] [options] SCRIPT [script-options]

Instead of: forever start bin/www -e logs/error.log -l logs/logs.log

Try: forever start -e /path/to/logs/error.log -l /path/to/logs/logs.log your_script.js

I had the same problem in OSX. In OSX (at least), the mand forever app.js starts the forever process in the foreground and doesn't write the log to file, even when -l and -e are provided. In this case, forever list lists the file even though it isn't there and forever logs i produces error: undefined.

When the forever DAEMON is started using forever start app.js, the log files do appear and can be viewed using forever logs i.

发布评论

评论列表(0)

  1. 暂无评论