Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated the memcached cookbook

  • Loading branch information...
commit 87365916a6b309db74879731f2b41b1355d60f51 1 parent e1d2a29
Sam Cooper sandfish8 authored
31 memcached/attributes/default.rb
View
@@ -1,22 +1,13 @@
-#
-# Cookbook Name:: memcached
-# Attributes:: default
-#
-# Copyright 2010, Blue Box Group, LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
+# Platform specific attributes
+case platform
+when "redhat","centos","fedora","scientific"
+ default[:memcached][:user] = "memcached"
+when "ubuntu","debian"
+ default[:memcached][:user] = "nobody"
+end
+# Configuration requirements.
default[:memcached][:port] = "11211"
-default[:memcached][:bindaddress] = "127.0.0.1"
-default[:memcached][:cache_size] = ((node[:memory][:total] * 0.9375) / 1024) / 1024
+default[:memcached][:maxconn] = "3072"
+default[:memcached][:cachesize] = "128M"
+default[:memcached][:options] = ""
44 memcached/recipes/default.rb
View
@@ -1,8 +1,7 @@
-#
-# Cookbook Name:: memcached
+# Cookbook Name:: git
# Recipe:: default
#
-# Copyright 2010, Blue Box Group, LLC
+# Copyright 2011, Blue Box Group, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,31 +14,32 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-#
-packages = [ "memcached" ]
+memcached_package = "memcached"
-cache_size = ((node[:memory][:total] * 0.9375) / 1024) / 1024
+case node[:platform]
+when "centos","redhat","fedora","scientific"
+ yum_package memcached_package do
+ arch node[:kernel][:machine]
+ end
+when "debian","ubuntu"
+ apt_package memcached_package
+end
-packages.each do |pkg|
- package "#{pkg}" do
- action :install
+template "memcached" do
+ case node[:platform]
+ when "centos","redhat","fedora","scientific"
+ path "/etc/sysconfig/memcached"
+ source "memcached.erb"
+ when "debian","ubuntu"
+ path "/etc/memcached.conf"
+ source "memcached.conf.erb"
end
+ backup false
+ notifies :restart, "service[memcached]", :immediately
end
service "memcached" do
- supports :status => true, :restart => true, :reload => true
+ supports :start => true, :stop => true, :restart => true
action [ :enable, :start ]
end
-
-template "/etc/sysconfig/memcached" do
- source "memcached.erb"
- mode 0644
- owner "root"
- group "root"
- variables(
- :cache_size => cache_size
- )
- action :create
- notifies :restart, "service[memcached]"
-end
10 memcached/templates/default/memcached.erb
View
@@ -1,5 +1,5 @@
-PORT="<%= node[:memcached][:port] %>"
-USER="memcached"
-MAXCONN="5120"
-OPTIONS="-l <%= node[:memcached][:bindaddress] %>"
-CACHESIZE="<%= node[:memcached][:cache_size] %>"
+PORT="<%= @node[:memcached][:port] %>"
+USER="<%= @node[:memcached][:user] %>"
+MAXCONN="<%= @node[:memcached][:maxconn] %>"
+CACHESIZE="<%= @node[:memcached][:cachesize] %>"
+OPTIONS="<%= @node[:memcached][:options] %>"
47 memcached/templates/ubuntu/memcached.conf.erb
View
@@ -0,0 +1,47 @@
+# Memcached default config file
+# 2003 - Jay Bonci <jaybonci@debian.org>
+# This configuration file is read by the start-memcached script provided as
+# part of the Debian GNU/Linux distribution.
+
+# Run memcached as a daemon. This command is implied, and is not needed for the
+# daemon to run. See the README.Debian that comes with this package for more
+# information.
+-d
+
+# Log memcached's output to /var/log/memcached
+logfile /var/log/memcached.log
+
+# Be verbose
+# -v
+
+# Be even more verbose (print client commands as well)
+# -vv
+
+# Start with a cap of <%= @node[:memcached][:cachesize] %> of memory.
+-m <%= @node[:memcached][:cachesize] %>
+
+# Default connection port is 11211
+-p <%= @node[:memcached][:port] %>
+
+# Run the daemon as root. The start-memcached will default to running as root if no
+# -u command is present in this config file
+# -u nobody
+-u <%= @node[:memcached][:user] %>
+
+# Specify which IP address to listen on. The default is to listen on all IP addresses
+# This parameter is one of the only security measures that memcached has, so make sure
+# it's listening on a firewalled interface.
+#-l 127.0.0.1
+
+# Limit the number of simultaneous incoming connections. The daemon default is 1024
+# -c 1024
+-c <%= @node[:memcached][:maxconn] %>
+
+# Lock down all paged memory. Consult with the README and homepage before you do this
+# -k
+
+# Return error when memory is exhausted (rather than removing items)
+# -M
+
+# Maximize core file limit
+# -r
Please sign in to comment.
Something went wrong with that request. Please try again.