1、安装:略
2、forever 按时间分log步骤:
1)、停止node项目
,命令(.bat文件):
forever_stop.bat:
forever stopall
2)、定时删除log文件(删除7天前,不包括当天),命令(.bat文件):
delLogs.bat:
SET APP_PATH=G:\www\demo1
SET APP=%APP_PATH%\app.js
SET LOGS=%APP_PATH%\logs
forfiles /p %LOGS% /s /m *.log /d -7 /c "cmd /c del @path"
3)、开启forever,并生成log文件(按天分割),命令(.bat文件):
forever_start.bat:
@echo off
SET CURRENT_DATE=%date:~0,4%-%date:~5,2%-%date:~8,2%
SET APP_PATH=G:\www\demo1
SET PID= %APP_PATH%\logs\forever.pid
SET APP=%APP_PATH%\app.js
SET LOGS=%APP_PATH%\logs
SET ACCESS= %LOGS%\access\%CURRENT_DATE%.log
SET ERROR=%LOGS%\error\%CURRENT_DATE%.log
SET OUT=%LOGS%\out\%CURRENT_DATE%.log
chdir /d %APP_PATH%
forever -p %APP_PATH% -l %ACCESS% -e %ERROR% -o %OUT% -a --pidFile %PID% start --max-old-space-size=4096 app.js
echo forever starting...
echo %CURRENT_DATE%
网友评论