开发者

possible to logrotate rails app with nginx passenger without restart?

It is possible to do logrotate without restarting nginx (just send USR1 sign开发者_如何学Goal to nginx it will do the job). I wonder it is possible for my rails app (nginx passenger). It's not worth to restart my rails apps just to do a logrotate.


logrotate configuration is pretty simple to get this down

/path/to/rails_apps/*/shared/log/*.log {
  daily
  missingok
  rotate 30
  compress
  delaycompress
  copytruncate
}

the copytruncate basically copies the content to new file and truncates the old file. this eliminates the need for restart.


If you are talking about rails application log rotation, you can do that by putting

 config.logger = Logger.new(config.log_path, 10, 1024**2)

in your environment file. The 2nd argument is the number of .log files you’d like to keep, and the 3rd being the size in bytes that the files are allowed to reach before they’ll be rotated. This configuration means 10 files of 1 megabyte. May not be quite as configurable as logrotate perhaps (no support for compression etc.), but it lets you keep all your log files within your app. This usually works for me.

Also found this if want to stick to log rotation via nginx.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜