Chamnap
Chamnap

Reputation: 4766

possible to logrotate rails app with nginx passenger without restart?

It is possible to do logrotate without restarting nginx (just send USR1 signal 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.

Upvotes: 6

Views: 4733

Answers (2)

Addy
Addy

Reputation: 1851

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.

Upvotes: 29

Chirantan
Chirantan

Reputation: 15634

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.

Upvotes: 3

Related Questions