为什么旋转原木时导轨会崩溃?在轨道上旋转原木的正确方法是什么?

发布于 2025-01-01 02:48:18 字数 450 浏览 3 评论 0原文

我不想经历使用 UNIX 的 logrotate 设置 4 个节点服务器(每个节点服务器有 3 个应用程序)的麻烦。

因此,我决定使用以下内部环境设置我的 Rails 应用程序。rb:

  log_path = "#{Rails.root}/log/#{ENV['RAILS_ENV']}.log"
  shift_age = 'weekly' # you can either 1) specify 2 params 50, 1024bytes OR 2) specify 1 param 'daily | weekly | monthly'
  config.logger = Logger.new(log_path, shift_age)

但是,一旦文件翻转,这会导致 Rails 应用程序中断。

我想知道,使用 Rails 应用程序旋转日志的最佳方法是什么?是对数旋转吗?谢谢。

I did not want to go through the headache of setting up 4 node-servers with 3 applications each by using logrotate for UNIX.

So I decided to setup my rails applications with the following inside environment.rb:

  log_path = "#{Rails.root}/log/#{ENV['RAILS_ENV']}.log"
  shift_age = 'weekly' # you can either 1) specify 2 params 50, 1024bytes OR 2) specify 1 param 'daily | weekly | monthly'
  config.logger = Logger.new(log_path, shift_age)

However, this caused the rails application to break once the files were rolled over.

I am wondering, what is the best way to rotate logs with rails applications? Is it logrotate? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温暖的光 2025-01-08 02:48:19

发生这种情况的原因是,一个进程尝试轮换日志文件的同时,另一个进程也尝试轮换日志文件,出现竞争条件,并且服务器停止响应请求,并引发致命异常

This happens because one process is trying to rotate the log file at the same time that the another process is trying to rotate it, a race condition occurs, and the server stops responding to requests, as a Fatal Exception is raise

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文