From 7066392f4a7e46ab783b4bc1fb8d8ff857230a92 Mon Sep 17 00:00:00 2001 From: Justin Burnham Date: Thu, 6 Nov 2014 15:20:19 -0800 Subject: [PATCH] Add support for custom and disabling of pidfiles. --- README.md | 1 + manifests/init.pp | 1 + spec/classes/memcached_spec.rb | 9 +++++++++ templates/memcached.conf.erb | 6 ++++-- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b552f7677..b2de3f30c 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ If you find this module useful, send some bitcoins to 1Na3YFUmdxKxJLiuRXQYJU2kiN * $package_ensure = 'present' * $logfile = '/var/log/memcached.log' +* $pidfile = '/var/run/memcached.pid' (Debian family only, set to false to disable pidfile) * $max_memory = false * $item_size = false * $lock_memory = false (WARNING: good if used intelligently, google for -k key) diff --git a/manifests/init.pp b/manifests/init.pp index 19f825f31..1b4919814 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -5,6 +5,7 @@ class memcached ( $package_ensure = 'present', $logfile = '/var/log/memcached.log', + $pidfile = '/var/run/memcached.pid', $manage_firewall = false, $max_memory = false, $item_size = false, diff --git a/spec/classes/memcached_spec.rb b/spec/classes/memcached_spec.rb index b40599f5d..9513b5a7c 100644 --- a/spec/classes/memcached_spec.rb +++ b/spec/classes/memcached_spec.rb @@ -94,6 +94,12 @@ :install_dev => true, :processorcount => 1 }, + { + :pidfile => false, + }, + { + :pidfile => '/var/log/memcached.pid', + }, { :package_ensure => 'absent', :install_dev => true @@ -183,6 +189,9 @@ if(param_hash[:lock_memory]) expected_lines.push("-k") end + if(param_hash[:pidfile]) + expected_lines.push("-P #{param_hash[:pidfile]}") + end if(param_hash[:verbosity]) expected_lines.push("-vvv") end diff --git a/templates/memcached.conf.erb b/templates/memcached.conf.erb index ede73d064..da9bb96da 100644 --- a/templates/memcached.conf.erb +++ b/templates/memcached.conf.erb @@ -3,8 +3,10 @@ # Run memcached as a daemon. -d +<% if @pidfile -%> # pidfile --P /var/run/memcached.pid +-P <%= @pidfile %> +<% end -%> # Log memcached's output logfile <%= @logfile -%> @@ -59,4 +61,4 @@ logfile <%= @logfile -%> <% if @auto_removal -%> # Disable automatic removal of items from the cache when out of memory -M -<% end -%> \ No newline at end of file +<% end -%>