Skip to content

Commit

Permalink
add mysql logratote default to mysql-server
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarah Zelechoski committed Nov 24, 2014
1 parent eab6a0a commit 031af6d
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion lib/moonshine/manifest/rails/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def mysql_server
:notify => service('mysql'),
:checksum => :md5

file '/etc/logrotate.d/varlogmysql.conf', :ensure => :absent
recipe :mysql_logrotate
end

# Install the <tt>mysql</tt> rubygem and dependencies
Expand Down Expand Up @@ -74,6 +74,28 @@ def mysql_fixup_debian_start
:require => package('mysql-server')
end

def mysql_logrotate
file '/etc/logrotate.d/varlogmysql.conf', :ensure => :absent
file '/etc/logrotate.d/mysql-server', :ensure => :absent

logrotate_options = configuration[:mysql][:logrotate] || {}
logrotate_options[:frequency] ||= 'daily'
logrotate_options[:count] ||= '7'
logrotate "/var/log/mysql/*.log",
:logrotated_file => 'apache2',
:options => [
logrotate_options[:frequency],
'missingok',
"rotate #{logrotate_options[:count]}",
'compress',
'delaycompress',
'notifempty',
'create 640 mysql adm',
'sharedscripts'
],
:postrotate => 'MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"; if [ -z "`$MYADMIN ping 2>/dev/null`" ]; then if ps cax | grep -q mysqld; then exit 1; fi ; else $MYADMIN flush-logs; fi'
end

private

# Internal helper to shell out and run a query. Doesn't select a database.
Expand Down

0 comments on commit 031af6d

Please sign in to comment.