Skip to content

Instantly share code, notes, and snippets.

@shimizukawa
Last active December 18, 2015 00:29
Show Gist options
  • Save shimizukawa/5697312 to your computer and use it in GitHub Desktop.
Save shimizukawa/5697312 to your computer and use it in GitHub Desktop.
Chef + CnetOS6 / RHEL6 + memcached + upstart
description "memcached"
start on runlevel [2345]
stop on runlevel [!2345]
#Send KILL after 5 seconds
respawn
respawn limit 5 60
env DAEMON=memcached
env PORT=11211
env USER=memcached
env MAXCONN=1024
env CACHESIZE=64
env OPTIONS="-l 0.0.0.0"
script
. /etc/sysconfig/memcached
exec memcached -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN $OPTIONS
end script
#
# Cookbook Name:: myrecipe
# Recipe:: memcached
#
# Copyright 2013, Takayuki SHIMIZUKAWA
#
# 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.
#
template "/etc/init/memcached.conf" do
owner "root"
group "root"
mode 0644
end
execute "rm /etc/init.d/memcached " do
action :nothing
subscribes :run, resources(:package => 'memcached'), :immediately
end
service "memcached" do
provider Chef::Provider::Service::Upstart
action :nothing
enabled true
running true
supports :status => true, :start => true, :stop => true, :restart => true
subscribes :restart, resources(:template => '/etc/init/memcached.conf')
end
{
"run_list": [
"recipe[memcached]",
"recipe[myrecipe::memcached]"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment