2 nodejs scripts are being handled by forever
. The system is using forever v0.11.1 and node v0.10.29
两个nodejs脚本将永远被处理。系统使用的是forever v0.11.1和节点v0.10.29
# forever list
info: Forever processes running
data: uid command 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!
目录/root/.forever也不显示日志文件!
# 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
3 个解决方案
#1
4
To answer Shreejibawa (since I can't comment yet)...
要回答什蕾吉巴娃(因为我还不能评论)……
forever is very sensitive to the order of the arguments. Take a look at their documentation and notice that the options must come before the script.
forever对参数的顺序非常敏感。看看他们的文档,注意选项必须放在脚本之前。
forever [action] [options] SCRIPT [script-options]
Instead of: forever start bin/www -e logs/error.log -l logs/logs.log
永远启动bin/www -e日志/错误。日志- l / logs.log日志
Try: forever start -e /path/to/logs/error.log -l /path/to/logs/logs.log your_script.js
尝试:永远启动-e /path/to/logs/error。日志- l /道路/ /日志/日志。日志your_script.js
#2
3
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:
如果您使用forever your_script启动节点进程。不指定日志文件,forever会将您的日志写到终端(或Windows上的cmd)。运行forever列表或forever日志时显示的日志文件不能反映实际情况,因为在该场景中没有创建日志文件。但如果您指定日志文件,请遵循以下选项:
-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.
就像永远的控制台。日志- e错误。日志your_script。日志,它们将被创建。
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.
如果您想永远为您自动创建日志文件,您必须以守护进程的形式启动脚本,并永远启动您的_script.js。在这种情况下,还可以指定日志文件。
In the docs page you can see all the command line options.
在docs页面中,您可以看到所有的命令行选项。
#3
0
I had the same problem in OSX. In OSX (at least), the command 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
.
我在OSX也有同样的问题。在OSX(至少)中,命令forever app.js在前台启动forever进程,即使提供了-l和-e,也不会将日志写到文件中。在这种情况下,永远列表列出了文件,即使它不存在,并且永远日志我生成了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
.
当forever守护进程开始使用forever start app.js时,日志文件确实会出现,并且可以使用forever log i查看日志文件。
#1
4
To answer Shreejibawa (since I can't comment yet)...
要回答什蕾吉巴娃(因为我还不能评论)……
forever is very sensitive to the order of the arguments. Take a look at their documentation and notice that the options must come before the script.
forever对参数的顺序非常敏感。看看他们的文档,注意选项必须放在脚本之前。
forever [action] [options] SCRIPT [script-options]
Instead of: forever start bin/www -e logs/error.log -l logs/logs.log
永远启动bin/www -e日志/错误。日志- l / logs.log日志
Try: forever start -e /path/to/logs/error.log -l /path/to/logs/logs.log your_script.js
尝试:永远启动-e /path/to/logs/error。日志- l /道路/ /日志/日志。日志your_script.js
#2
3
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:
如果您使用forever your_script启动节点进程。不指定日志文件,forever会将您的日志写到终端(或Windows上的cmd)。运行forever列表或forever日志时显示的日志文件不能反映实际情况,因为在该场景中没有创建日志文件。但如果您指定日志文件,请遵循以下选项:
-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.
就像永远的控制台。日志- e错误。日志your_script。日志,它们将被创建。
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.
如果您想永远为您自动创建日志文件,您必须以守护进程的形式启动脚本,并永远启动您的_script.js。在这种情况下,还可以指定日志文件。
In the docs page you can see all the command line options.
在docs页面中,您可以看到所有的命令行选项。
#3
0
I had the same problem in OSX. In OSX (at least), the command 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
.
我在OSX也有同样的问题。在OSX(至少)中,命令forever app.js在前台启动forever进程,即使提供了-l和-e,也不会将日志写到文件中。在这种情况下,永远列表列出了文件,即使它不存在,并且永远日志我生成了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
.
当forever守护进程开始使用forever start app.js时,日志文件确实会出现,并且可以使用forever log i查看日志文件。