Skip to content

Commit

Permalink
update memcached to use the package defaults with a template
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimberman committed Oct 22, 2009
1 parent c9e6255 commit 7c93bc6
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 24 deletions.
4 changes: 3 additions & 1 deletion README.rdoc
Expand Up @@ -6,7 +6,7 @@ Installs memcached and provides a define to set up an instance of memcache via r

== Platform:

Tested on Ubuntu 8.10. Uses the memcached package but disables the service and uses runit, see below.
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 included define.

== Cookbooks:

Expand All @@ -24,6 +24,8 @@ The following are node attributes passed to the template for the runit service.

= 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"
Expand Down
42 changes: 21 additions & 21 deletions metadata.json
@@ -1,72 +1,72 @@
{
"maintainer": "Opscode, Inc.",
"description": "Installs memcached and provides a define to set up an instance of memcache via runit",
"replacing": {
"recommendations": {

},
"maintainer_email": "cookbooks@opscode.com",
"recipes": {
"memcached": ""
},
"platforms": {
"suggestions": {

},
"maintainer": "Opscode, Inc.",
"version": "0.7.0",
"recommendations": {
"platforms": {

},
"version": "0.8.0",
"name": "memcached",
"maintainer_email": "cookbooks@opscode.com",
"conflicting": {

},
"attributes": {
"memcached\/memory": {
"default": "64",
"type": "string",
"multiple_values": false,
"description": "Memory allocated for memcached instance",
"display_name": "Memcached Memory",
"required": false,
"recipes": [

]
],
"required": false
},
"memcached\/user": {
"default": "nobody",
"type": "string",
"multiple_values": false,
"description": "User to run memcached instance as",
"display_name": "Memcached User",
"required": false,
"recipes": [

]
],
"required": false
},
"memcached\/port": {
"default": "11211",
"type": "string",
"multiple_values": false,
"description": "Port to use for memcached instance",
"display_name": "Memcached Port",
"required": false,
"recipes": [

]
],
"required": false
}
},
"suggestions": {
"providing": {
"memcached": [

]
},
"license": "Apache 2.0",
"conflicting": {
"long_description": "= DESCRIPTION:\n\nInstalls memcached and provides a define to set up an instance of memcache via runit.\n\n= REQUIREMENTS:\n\n== Platform:\n\nTested on Ubuntu 8.10. Uses the memcached package by default. A runit service can be set up for instances using the included define.\n\n== Cookbooks:\n\nOpscode cookbooks, http:\/\/github.com\/opscode\/cookbooks\/tree\/master:\n\n* runit\n\n= ATTRIBUTES: \n\nThe following are node attributes passed to the template for the runit service.\n\n* memcached[:memory] - maximum memory for memcached instances.\n* memcached[:user] - user to run memcached as.\n* memcached[:port] - port for memcached to listen on.\n\n= USAGE:\n\nUse the define, memcached_instance, to set up a runit service for the named memcached instance.\n\n memcached_instance \"myproj\" \n\n= LICENSE and AUTHOR:\n\nAuthor:: Joshua Timberman (<joshua@opscode.com>)\nAuthor:: Joshua Sierles (<joshua@37signals.com>)\n\nCopyright:: 2009, Opscode, Inc\nCopyright:: 2009, 37signals\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
"replacing": {

},
"dependencies": {
"runit": [

]
},
"providing": {
"memcached": [

]
},
"long_description": "= DESCRIPTION:\n\nInstalls memcached and provides a define to set up an instance of memcache via runit.\n\n= REQUIREMENTS:\n\n== Platform:\n\nTested on Ubuntu 8.10. Uses the memcached package but disables the service and uses runit, see below.\n\n== Cookbooks:\n\nOpscode cookbooks, http:\/\/github.com\/opscode\/cookbooks\/tree\/master:\n\n* runit\n\n= ATTRIBUTES: \n\nThe following are node attributes passed to the template for the runit service.\n\n* memcached[:memory] - maximum memory for memcached instances.\n* memcached[:user] - user to run memcached as.\n* memcached[:port] - port for memcached to listen on.\n\n= USAGE:\n\nUse the define, memcached_instance, to set up a runit service for the named memcached instance.\n\n memcached_instance \"myproj\" \n\n= LICENSE and AUTHOR:\n\nAuthor:: Joshua Timberman (<joshua@opscode.com>)\nAuthor:: Joshua Sierles (<joshua@37signals.com>)\n\nCopyright:: 2009, Opscode, Inc\nCopyright:: 2009, 37signals\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n"
}
}
2 changes: 1 addition & 1 deletion metadata.rb
Expand Up @@ -3,7 +3,7 @@
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.rdoc'))
version "0.7"
version "0.8"
depends "runit"

attribute "memcached/memory",
Expand Down
16 changes: 15 additions & 1 deletion recipes/default.rb
Expand Up @@ -26,5 +26,19 @@
end

service "memcached" do
action :disable
action :nothing
end

template "/etc/memcached.conf" do
source "memcached.conf.erb"
owner "root"
group "root"
mode "0644"
variables(
:ipaddress => node[:ipaddress],
:user => node[:memcached][:user],
:port => node[:memcached][:port],
:memory => node[:memcached][:memory]
)
notifies :restart, resources(:service => "memcached"), :immediately
end
50 changes: 50 additions & 0 deletions 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 <%= @ipaddress %>

# 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

0 comments on commit 7c93bc6

Please sign in to comment.