From 22dd8186d9d5a421c19039c1211813bf97a6bb1c Mon Sep 17 00:00:00 2001 From: Darren Foo Date: Tue, 23 Jun 2015 22:21:14 -0700 Subject: [PATCH] add `logfilepath` attribute --- attributes/default.rb | 1 + definitions/memcached_instance.rb | 18 +++++++++--------- recipes/configure.rb | 4 ++++ templates/default/memcached.conf.erb | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index f3adbee..d0e9426 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -24,6 +24,7 @@ default['memcached']['listen'] = '0.0.0.0' default['memcached']['maxconn'] = 1024 default['memcached']['max_object_size'] = '1m' +default['memcached']['logfilepath'] = '/var/log/' default['memcached']['logfilename'] = 'memcached.log' case node['platform_family'] diff --git a/definitions/memcached_instance.rb b/definitions/memcached_instance.rb index 77118b1..d763e10 100644 --- a/definitions/memcached_instance.rb +++ b/definitions/memcached_instance.rb @@ -30,16 +30,16 @@ default_logger true cookbook 'memcached' options({ - :memory => node['memcached']['memory'], - :port => node['memcached']['port'], - :udp_port => node['memcached']['udp_port'], - :listen => node['memcached']['listen'], - :maxconn => node['memcached']['maxconn'], - :user => node['memcached']['user'], - :threads => node['memcached']['threads'], - :max_object_size => node['memcached']['max_object_size'], + :memory => node['memcached']['memory'], + :port => node['memcached']['port'], + :udp_port => node['memcached']['udp_port'], + :listen => node['memcached']['listen'], + :maxconn => node['memcached']['maxconn'], + :user => node['memcached']['user'], + :threads => node['memcached']['threads'], + :max_object_size => node['memcached']['max_object_size'], :experimental_options => Array(node['memcached']['experimental_options']), - :ulimit => node['memcached']['ulimit'] + :ulimit => node['memcached']['ulimit'] }.merge(opts)) end end diff --git a/recipes/configure.rb b/recipes/configure.rb index 5086c48..301b477 100644 --- a/recipes/configure.rb +++ b/recipes/configure.rb @@ -17,6 +17,8 @@ # limitations under the License. # +directory node['memcached']['logfilepath'] + service 'memcached' do action :enable supports :status => true, :start => true, :stop => true, :restart => true, :enable => true @@ -38,6 +40,7 @@ :udp_port => node['memcached']['udp_port'], :maxconn => node['memcached']['maxconn'], :memory => node['memcached']['memory'], + :logfilepath => node['memcached']['logfilepath'], :logfilename => node['memcached']['logfilename'], :threads => node['memcached']['threads'], :max_object_size => node['memcached']['max_object_size'] @@ -63,6 +66,7 @@ :udp_port => node['memcached']['udp_port'], :maxconn => node['memcached']['maxconn'], :memory => node['memcached']['memory'], + :logfilepath => node['memcached']['logfilepath'], :logfilename => node['memcached']['logfilename'], :threads => node['memcached']['threads'], :max_object_size => node['memcached']['max_object_size'], diff --git a/templates/default/memcached.conf.erb b/templates/default/memcached.conf.erb index 474f39a..78b7f76 100644 --- a/templates/default/memcached.conf.erb +++ b/templates/default/memcached.conf.erb @@ -12,7 +12,7 @@ -d # Log memcached's output to /var/log/memcached -logfile /var/log/<%= @logfilename %> +logfile <%= @logfilepath %><%= @logfilename %> # Be verbose -v