Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Import memcached version 1.0.0

  • Loading branch information...
commit 55c2e7e5d13cda09eb99fc6047bca348e79ce1da 1 parent d2237f7
@smith smith authored
View
71 memcached/README.md
@@ -0,0 +1,71 @@
+Description
+===========
+
+Installs memcached and provides a define to set up an instance of
+memcache via runit.
+
+Changes
+=======
+
+## v1.0.0:
+
+* [COOK-706] - Additional info in README
+* [COOK-828] - Package for RHEL systems
+
+## v0.10.4:
+
+* Current released version
+
+Requirements
+============
+
+Tested on Ubuntu 8.10-9.10. Uses the memcached init script by default.
+A runit service can be set up for instances using the
+`memcache_instance` definition.
+
+## Cookbooks:
+
+* runit
+
+Attributes
+==========
+
+The following are node attributes passed to the template for the runit
+service.
+
+* `memcached[:memory]` - maximum memory for memcached instances.
+* `memcached[:user]` - user to run memcached as.
+* `memcached[:port]` - port for memcached to listen on.
+* `memcached[:listen]` - IP address for memcached to listen on.
+
+Usage
+=====
+
+Simply set the attributes and it will configure the /etc/memcached.conf file. If you want to use multiple memcached instances, you'll need to modify the recipe to disable the startup script and the template in the default recipe.
+
+Use the define, memcached_instance, to set up a runit service for the named memcached instance.
+
+ memcached_instance "myproj"
+
+The recipe also reads in whether to start up memcached from a /etc/default/memcached "ENABLE_MEMCACHED" setting, which is "yes" by default.
+
+License and Author
+==================
+
+Author:: Joshua Timberman (<joshua@opscode.com>)
+Author:: Joshua Sierles (<joshua@37signals.com>)
+
+Copyright:: 2009, Opscode, Inc
+Copyright:: 2009, 37signals
+
+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.
View
4 memcached/attributes/default.rb
@@ -0,0 +1,4 @@
+default[:memcached][:memory] = 64
+default[:memcached][:port] = 11211
+default[:memcached][:user] = "nobody"
+default[:memcached][:listen] = "0.0.0.0"
View
32 memcached/definitions/memcached_instance.rb
@@ -0,0 +1,32 @@
+#
+# Cookbook Name:: memcached
+# Definition:: memcached_instance
+#
+# Copyright 2009, Opscode, Inc.
+#
+# 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.
+#
+
+define :memcached_instance do
+ include_recipe "memcached"
+
+ runit_service "memcached-#{params[:name]}" do
+ template_name "memcached"
+ cookbook "memcached"
+ options({
+ :memory => node[:memcached][:memory],
+ :port => node[:memcached][:port],
+ :user => node[:memcached][:user]}.merge(params)
+ )
+ end
+end
View
33 memcached/metadata.rb
@@ -0,0 +1,33 @@
+maintainer "Opscode, Inc."
+maintainer_email "cookbooks@opscode.com"
+license "Apache 2.0"
+description "Installs memcached and provides a define to set up an instance of memcache via runit"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version "1.0.0"
+depends "runit"
+
+recipe "memcached", "Installs and configures memcached"
+
+%w{ ubuntu debian }.each do |os|
+ supports os
+end
+
+attribute "memcached/memory",
+ :display_name => "Memcached Memory",
+ :description => "Memory allocated for memcached instance",
+ :default => "64"
+
+attribute "memcached/port",
+ :display_name => "Memcached Port",
+ :description => "Port to use for memcached instance",
+ :default => "11211"
+
+attribute "memcached/user",
+ :display_name => "Memcached User",
+ :description => "User to run memcached instance as",
+ :default => "nobody"
+
+attribute "memcached/listen",
+ :display_name => "Memcached IP Address",
+ :description => "IP address to use for memcached instance",
+ :default => "0.0.0.0"
View
62 memcached/recipes/default.rb
@@ -0,0 +1,62 @@
+#
+# Cookbook Name:: memcached
+# Recipe:: default
+#
+# Copyright 2009, Opscode, Inc.
+#
+# 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.
+#
+
+package "memcached" do
+ action :upgrade
+end
+
+package "libmemcache-dev" do
+ case node[:platform]
+ when "redhat","centos","fedora"
+ package_name "libmemcache-devel"
+ else
+ package_name "libmemcache-dev"
+ end
+ action :upgrade
+end
+
+service "memcached" do
+ action :nothing
+ supports :status => true, :start => true, :stop => true, :restart => true
+end
+
+template "/etc/memcached.conf" do
+ source "memcached.conf.erb"
+ owner "root"
+ group "root"
+ mode "0644"
+ variables(
+ :listen => node[:memcached][:listen],
+ :user => node[:memcached][:user],
+ :port => node[:memcached][:port],
+ :memory => node[:memcached][:memory]
+ )
+ notifies :restart, resources(:service => "memcached"), :immediately
+end
+
+case node[:lsb][:codename]
+when "karmic"
+ template "/etc/default/memcached" do
+ source "memcached.default.erb"
+ owner "root"
+ group "root"
+ mode "0644"
+ notifies :restart, resources(:service => "memcached"), :immediately
+ end
+end
View
50 memcached/templates/default/memcached.conf.erb
@@ -0,0 +1,50 @@
+#
+# Configured by Chef. Logcal changes will be lost.
+#
+# 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 64 megs of memory. It's reasonable, and the daemon default
+# Note that the daemon will grow to this size, but does not start out holding this much
+# memory
+-m <%= @memory %>
+
+# Default connection port is 11211
+-p <%= @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 <%= @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 <%= @listen %>
+
+# Limit the number of simultaneous incoming connections. The daemon default is 1024
+# -c 1024
+
+# 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
View
2  memcached/templates/default/memcached.default.erb
@@ -0,0 +1,2 @@
+# Set this to yes to enable memcached.
+ENABLE_MEMCACHED=yes
View
2  memcached/templates/default/sv-memcached-log-run.erb
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec svlogd -tt ./main
View
3  memcached/templates/default/sv-memcached-run.erb
@@ -0,0 +1,3 @@
+#!/bin/sh
+exec 2>&1
+exec chpst -u <%= @options[:user] %> /usr/bin/memcached -v -m <%= @options[:memory] %> -p <%= @options[:port] %>
Please sign in to comment.
Something went wrong with that request. Please try again.