-
-
Save vitaliel/4462156 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate logrotate conf for rails sites deployed with capistrano | |
# it scans current directory for rails site, it assumes that webserver is passenger | |
# cd /u/apps && ~/bin/gen_logrotate.rb | |
require 'etc' | |
Dir['*'].each do |entry| | |
next unless File.directory? entry | |
dir = File.expand_path entry | |
log_dir = dir + "/shared/log" | |
next unless File.directory? log_dir | |
puts dir | |
fstats = File.stat dir | |
user = Etc.getpwuid(fstats.uid).name | |
group = Etc.getgrgid(fstats.gid).name | |
File.open "#{entry.tr('.', '_')}_conf", "w" do |out| | |
out.write <<EOF | |
#{log_dir}/*.log { | |
daily | |
missingok | |
rotate 5 | |
notifempty | |
create 640 #{user} #{group} | |
sharedscripts | |
postrotate | |
/bin/date >#{dir}/current/tmp/restart.txt | |
endscript | |
} | |
EOF | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment