зеркало из https://github.com/mozilla/labs-vcap.git
Merge "Dev setup support for memcached as a service"
This commit is contained in:
Коммит
b31c1af7b0
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env ruby
|
||||
# Copyright (c) 2009-2011 VMware, Inc.
|
||||
|
||||
exec(File.expand_path("../../../services/memcached/bin/memcached_gateway", __FILE__), *ARGV)
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
exec(File.expand_path("../../../services/memcached/bin/memcached_node", __FILE__), *ARGV)
|
|
@ -81,6 +81,13 @@ class Component
|
|||
Run.services.include? name
|
||||
end
|
||||
|
||||
DEFAULT_CLOUD_FOUNDRY_EXCLUDED_COMPONENT = 'neo4j|memcached|couchdb'
|
||||
def is_excluded?
|
||||
@excluded ||= ENV['CLOUD_FOUNDRY_EXCLUDED_COMPONENT']
|
||||
@excluded ||= DEFAULT_CLOUD_FOUNDRY_EXCLUDED_COMPONENT
|
||||
name.match(@excluded)
|
||||
end
|
||||
|
||||
def exists?
|
||||
File.exists? @path
|
||||
end
|
||||
|
@ -439,7 +446,8 @@ module Run
|
|||
args = Run.expand_args(args)
|
||||
components = args.map do |arg|
|
||||
component = Component.new(arg)
|
||||
component if component.exists?
|
||||
STDOUT.puts "Skipping excluded component: #{component.name}" if component.is_excluded?
|
||||
component if (component.exists? && !component.is_excluded?)
|
||||
end.compact
|
||||
STDERR.puts "Don't know how to process '#{args.inspect}' \?\?" if components.empty?
|
||||
components
|
||||
|
|
|
@ -25,7 +25,7 @@ default[:cloud_controller][:staging][:standalone] = "standalone.yml"
|
|||
default[:cloud_controller][:staging][:play] = "play.yml"
|
||||
|
||||
# Default builtin services
|
||||
default[:cloud_controller][:builtin_services] = ["redis", "mongodb", "mysql", "neo4j", "rabbitmq"]
|
||||
default[:cloud_controller][:builtin_services] = ["redis", "mongodb", "mysql", "neo4j", "rabbitmq", "memcached"]
|
||||
|
||||
# Default capacity
|
||||
default[:capacity][:max_uris] = 4
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
= DESCRIPTION:
|
||||
|
||||
= REQUIREMENTS:
|
||||
|
||||
= ATTRIBUTES:
|
||||
|
||||
= USAGE:
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
include_attribute "deployment"
|
||||
default[:libevent][:version] = "2.0.19"
|
||||
default[:memcached][:version] = "1.4.13"
|
||||
default[:memcached][:path] = File.join(node[:deployment][:home], "deploy", "memcached")
|
||||
default[:memcached][:runner] = node[:deployment][:user]
|
||||
default[:memcached][:password] = "memcached"
|
||||
|
||||
default[:memcached_node][:index] = "0"
|
||||
default[:memcached_node][:capacity] = "5"
|
||||
default[:memcached_node][:token] = "changememcachedtoken"
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"version": "1.0.0",
|
||||
"conflicting": {
|
||||
},
|
||||
"providing": {
|
||||
},
|
||||
"maintainer": "VMware",
|
||||
"replacing": {
|
||||
},
|
||||
"license": "TBD",
|
||||
"maintainer_email": "TBD",
|
||||
"long_description": "= DESCRIPTION:\n\n= REQUIREMENTS:\n\n= ATTRIBUTES:\n\n= USAGE:\n\n",
|
||||
"groupings": {
|
||||
},
|
||||
"dependencies": {
|
||||
"runit": [
|
||||
|
||||
],
|
||||
"env": [
|
||||
|
||||
]
|
||||
},
|
||||
"attributes": {
|
||||
},
|
||||
"recommendations": {
|
||||
},
|
||||
"name": "memcached",
|
||||
"suggestions": {
|
||||
},
|
||||
"description": "Installs/Configures memcached",
|
||||
"recipes": {
|
||||
},
|
||||
"platforms": {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
maintainer "VMware"
|
||||
maintainer_email "support@vmware.com"
|
||||
license "Apache 2.0"
|
||||
description "Installs/Configures Memcached"
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
|
||||
version "1.0.0"
|
|
@ -0,0 +1,67 @@
|
|||
remote_file File.join("", "tmp", "libevent-#{node[:libevent][:version]}-stable.tar.gz") do
|
||||
owner node[:deployment][:user]
|
||||
source "https://github.com/downloads/libevent/libevent/libevent-#{node[:libevent][:version]}-stable.tar.gz"
|
||||
not_if { ::File.exists?(File.join("", "tmp", "libevent-#{node[:libevent][:version]}-stable.tar.gz")) }
|
||||
end
|
||||
|
||||
remote_file File.join("", "tmp", "memcached-#{node[:memcached][:version]}.tar.gz") do
|
||||
owner node[:deployment][:user]
|
||||
source "http://memcached.googlecode.com/files/memcached-#{node[:memcached][:version]}.tar.gz"
|
||||
not_if { ::File.exists?(File.join("", "tmp", "memcached-#{node[:memcached][:version]}.tar.gz")) }
|
||||
end
|
||||
|
||||
directory "#{node[:memcached][:path]}" do
|
||||
owner node[:deployment][:user]
|
||||
group node[:deployment][:user]
|
||||
mode "0755"
|
||||
end
|
||||
|
||||
%w[bin etc var].each do |dir|
|
||||
directory File.join(node[:memcached][:path], dir) do
|
||||
owner node[:deployment][:user]
|
||||
group node[:deployment][:user]
|
||||
mode "0755"
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
end
|
||||
|
||||
bash "Compile libevent" do
|
||||
cwd File.join("", "tmp")
|
||||
user node[:deployment][:user]
|
||||
code <<-EOH
|
||||
tar xzf libevent-#{node[:libevent][:version]}-stable.tar.gz
|
||||
cd libevent-#{node[:libevent][:version]}-stable
|
||||
./configure --prefix=`pwd`/tmp
|
||||
make
|
||||
EOH
|
||||
not_if do
|
||||
::File.exists?(File.join(node[:memcached][:path], "bin", "memcached"))
|
||||
end
|
||||
end
|
||||
|
||||
bash "Install and configure sasldb" do
|
||||
user node[:deployment][:user]
|
||||
code <<-EOH
|
||||
sudo apt-get install sasl2-bin libsasl2-dev -y
|
||||
sudo sed -i 's/START=no/START=yes/' /etc/default/saslauthd
|
||||
sudo /etc/init.d/saslauthd start
|
||||
echo "password" | saslpasswd2 -c -a test testuser -p
|
||||
sudo chown #{node[:deployment][:user]} /etc/sasldb2
|
||||
EOH
|
||||
end
|
||||
|
||||
bash "Install memcached" do
|
||||
cwd File.join("", "tmp")
|
||||
user node[:deployment][:user]
|
||||
code <<-EOH
|
||||
tar xzf memcached-#{node[:memcached][:version]}.tar.gz
|
||||
cd memcached-#{node[:memcached][:version]}
|
||||
./configure --enable-sasl --with-libevent=../libevent-#{node[:libevent][:version]}-stable/tmp
|
||||
make
|
||||
cp memcached #{File.join(node[:memcached][:path], "bin")}
|
||||
EOH
|
||||
not_if do
|
||||
::File.exists?(File.join(node[:memcached][:path], "bin", "memcached"))
|
||||
end
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
#
|
||||
# Cookbook Name:: gateway
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2011, VMware
|
||||
#
|
||||
|
||||
cloudfoundry_service "memcached" do
|
||||
components ["memcached_gateway"]
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
#
|
||||
# Cookbook Name:: node
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2011, VMware
|
||||
#
|
||||
|
||||
cloudfoundry_service "memcached" do
|
||||
components ["memcached_node"]
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
cloud_controller_uri: <%= node[:cloud_controller][:service_api_uri] %>
|
||||
service:
|
||||
name: memcached
|
||||
version: "1.4"
|
||||
description: "Memcached in-memory object cache service"
|
||||
plans: ['free']
|
||||
tags: ['memcached', 'memcached-1.4', 'key-value', 'cache']
|
||||
index: 0
|
||||
token: <%= node[:memcached_node][:token] %>
|
||||
mbus: nats://<%= node[:nats_server][:user] %>:<%= node[:nats_server][:password] %>@<%= node[:nats_server][:host] %>:<%= node[:nats_server][:port] %>/
|
||||
pid: /var/vcap/sys/run/memcached_gateway.pid
|
||||
logging:
|
||||
level: debug
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
capacity: <%= node[:memcached_node][:capacity] %>
|
||||
plan: free
|
||||
local_db: sqlite3:/var/vcap/services/memcached/memcached_node.db
|
||||
mbus: nats://<%= node[:nats_server][:user] %>:<%= node[:nats_server][:password] %>@<%= node[:nats_server][:host] %>:<%= node[:nats_server][:port] %>/
|
||||
index: <%= node[:memcached_node][:index] %>
|
||||
base_dir: /var/vcap/services/memcached/instances
|
||||
memcached_log_dir: /var/vcap/services/memcached/logs
|
||||
pid: /var/vcap/sys/run/memcached_node.pid
|
||||
node_id: <%= "memcached_node_#{node[:memcached_node][:index]}" %>
|
||||
memcached_server_path: <%= File.join(node[:memcached][:path], "bin", "memcached") %>
|
||||
port_range:
|
||||
first: 11000
|
||||
last: 11050
|
||||
logging:
|
||||
level: debug
|
||||
memcached_memory: 16
|
||||
max_clients: 1024
|
|
@ -20,7 +20,7 @@ class JobManager
|
|||
ACM = "acm"
|
||||
ACMDB = "acmdb"
|
||||
|
||||
SERVICES = ["redis", "mysql", "mongodb", "neo4j", "rabbitmq"]
|
||||
SERVICES = ["redis", "mysql", "mongodb", "neo4j", "rabbitmq", "memcached"]
|
||||
SERVICES_NODE = SERVICES.map do |service|
|
||||
"#{service}_node"
|
||||
end
|
||||
|
@ -39,7 +39,7 @@ class JobManager
|
|||
# List of the required properties for jobs
|
||||
INSTALLED_JOB_PROPERTIES = {NATS => ["host"], CC => ["service_api_uri", "builtin_services"],
|
||||
CCDB => ["host"]}
|
||||
INSTALL_JOB_PROPERTIES = {CC => ["builtin_services"], MYSQL_NODE => ["index"], MONGODB_NODE => ["index"], REDIS_NODE => ["index"], NEO4J_NODE => ["index"], RABBITMQ_NODE => ["index"]}
|
||||
INSTALL_JOB_PROPERTIES = {CC => ["builtin_services"], MYSQL_NODE => ["index"], MONGODB_NODE => ["index"], REDIS_NODE => ["index"], NEO4J_NODE => ["index"], RABBITMQ_NODE => ["index"], MEMCACHED_NODE => ["index"]}
|
||||
|
||||
# Dependency between JOBS and components that are consumed by "vcap_dev" when cf is started or
|
||||
# stopped
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "memcached_gateway",
|
||||
"override_attributes": {},
|
||||
"json_class": "Chef::Role",
|
||||
"description": "Memcached service gateway",
|
||||
"chef_type": "role",
|
||||
"run_list" : [ "recipe[deployment]",
|
||||
"recipe[essentials]",
|
||||
"recipe[ruby]",
|
||||
"recipe[memcached::gateway]"]
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "memcached_node",
|
||||
"override_attributes": {},
|
||||
"json_class": "Chef::Role",
|
||||
"description": "Memcached service node",
|
||||
"chef_type": "role",
|
||||
"run_list" : ["recipe[deployment]",
|
||||
"recipe[essentials]",
|
||||
"recipe[ruby]",
|
||||
"recipe[memcached]",
|
||||
"recipe[memcached::node]"]
|
||||
}
|
|
@ -9,7 +9,7 @@ module CoreComponents
|
|||
end
|
||||
|
||||
def components
|
||||
%w[cloud_controller dea health_manager router stager acm services/redis services/mysql services/mongodb services/postgresql services/neo4j services/rabbit]
|
||||
%w[cloud_controller dea health_manager router stager acm services/redis services/mysql services/mongodb services/postgresql services/neo4j services/rabbit services/memcached]
|
||||
end
|
||||
|
||||
def dirs
|
||||
|
|
Загрузка…
Ссылка в новой задаче