зеркало из https://github.com/mozilla/labs-vcap.git
Merge "Add rabbitmq service support in dev_setup" into services-r9
This commit is contained in:
Коммит
75edaea0af
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
ENV['BUNDLE_GEMFILE'] = File.dirname(__FILE__) + '/../../services/rabbit/Gemfile'
|
||||
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../services/rabbit')
|
||||
|
||||
require 'rabbit_service'
|
|
@ -21,7 +21,7 @@ default[:cloud_controller][:staging][:django] = "django.yml"
|
|||
default[:cloud_controller][:staging][:wsgi] = "wsgi.yml"
|
||||
|
||||
# Default builtin services
|
||||
default[:cloud_controller][:builtin_services] = ["redis", "mongodb", "mysql", "neo4j"]
|
||||
default[:cloud_controller][:builtin_services] = ["redis", "mongodb", "mysql", "neo4j", "rabbitmq"]
|
||||
|
||||
# Default capacity
|
||||
default[:capacity][:max_uris] = 4
|
||||
|
|
|
@ -13,5 +13,8 @@ define :cloudfoundry_service do
|
|||
mode 0644
|
||||
end
|
||||
end
|
||||
cf_bundle_install(File.expand_path(File.join(node[:cloudfoundry][:path], "services", params[:name])))
|
||||
service_name = params[:name]
|
||||
# Work around for RabbitMQ service since its directory name is "rabbit"
|
||||
service_name = "rabbit" if service_name == "rabbitmq"
|
||||
cf_bundle_install(File.expand_path(File.join(node[:cloudfoundry][:path], "services", service_name)))
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ bash "Install Erlang" do
|
|||
code <<-EOH
|
||||
tar xvzf otp_src_#{node[:erlang][:version]}.tar.gz
|
||||
cd otp_src_#{node[:erlang][:version]}
|
||||
#{File.join(".", "configure")} --prefix=#{node[:erlang][:path]}
|
||||
#{File.join(".", "configure")} --prefix=#{node[:erlang][:path]} --disable-hipe
|
||||
make
|
||||
make install
|
||||
EOH
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
default[:rabbitmq][:version] = "2.4.0"
|
||||
default[:rabbitmq][:version_full] = "2.4.0-1_all"
|
||||
default[:rabbitmq][:source] = "http://www.rabbitmq.com/releases/rabbitmq-server/v#{rabbitmq[:version]}/rabbitmq-server_#{rabbitmq[:version_full]}.deb"
|
||||
include_attribute "deployment"
|
||||
default[:rabbitmq][:version] = "2.4.1"
|
||||
default[:rabbitmq][:version_full] = "generic-unix-2.4.1"
|
||||
default[:rabbitmq][:path] = File.join(node[:deployment][:home], "deploy", "rabbitmq")
|
||||
default[:rabbitmq][:source] = "http://www.rabbitmq.com/releases/rabbitmq-server/v#{rabbitmq[:version]}/rabbitmq-server-#{rabbitmq[:version_full]}.tar.gz"
|
||||
default[:rabbitmq][:plugins] = ["amqp_client", "mochiweb", "rabbitmq-management", "rabbitmq-management-agent", "rabbitmq-mochiweb", "webmachine"]
|
||||
default[:rabbitmq][:plugins_source] = "http://www.rabbitmq.com/releases/plugins/v#{rabbitmq[:version]}/"
|
||||
|
||||
default[:rabbitmq_node][:index] = "0"
|
||||
default[:rabbitmq_node][:token] = "changerabbitmqtoken"
|
||||
|
|
|
@ -10,18 +10,49 @@ case node['platform']
|
|||
when "ubuntu"
|
||||
package "erlang-nox"
|
||||
|
||||
remote_file File.join("", "tmp", "rabbitmq-server_#{node[:rabbitmq][:version_full]}.deb") do
|
||||
remote_file File.join("", "tmp", "rabbitmq-server-#{node[:rabbitmq][:version_full]}.tar.gz") do
|
||||
owner node[:deployment][:user]
|
||||
source node[:rabbitmq][:source]
|
||||
not_if { ::File.exists?(File.join("", "tmp", "rabbitmq-server_#{node[:rabbitmq][:version_full]}.deb")) }
|
||||
not_if { ::File.exists?(File.join("", "tmp", "rabbitmq-server-#{node[:rabbitmq][:version_full]}.tar.gz")) }
|
||||
end
|
||||
|
||||
node[:rabbitmq][:plugins].each do |plugin_name|
|
||||
remote_file File.join("", "tmp", "#{plugin_name}-#{node[:rabbitmq][:version]}.ez") do
|
||||
owner node[:deployment][:user]
|
||||
source "#{node[:rabbitmq][:plugins_source]}#{plugin_name}-#{node[:rabbitmq][:version]}.ez"
|
||||
not_if { ::File.exists?(File.join("", "tmp", "#{plugin_name}-#{node[:rabbitmq][:version]}.ez")) }
|
||||
end
|
||||
end
|
||||
|
||||
directory "#{node[:rabbitmq][:path]}" do
|
||||
owner node[:deployment][:user]
|
||||
group node[:deployment][:user]
|
||||
mode "0755"
|
||||
end
|
||||
|
||||
bash "Install RabbitMQ" do
|
||||
cwd File.join("", "tmp")
|
||||
user node[:deployment][:user]
|
||||
code <<-EOH
|
||||
dpkg -i rabbitmq-server_#{node[:rabbitmq][:version_full]}.deb
|
||||
tar xzf rabbitmq-server-#{node[:rabbitmq][:version_full]}.tar.gz
|
||||
cd rabbitmq_server-#{node[:rabbitmq][:version]}
|
||||
cp -rf * #{node[:rabbitmq][:path]}
|
||||
EOH
|
||||
not_if do
|
||||
::File.exists?(File.join("", "usr", "sbin", "rabbitmq-server"))
|
||||
::File.exists?(File.join(node[:rabbitmq][:path], "sbin", "rabbitmq-server"))
|
||||
end
|
||||
end
|
||||
|
||||
node[:rabbitmq][:plugins].each do |plugin_name|
|
||||
bash "Install RabbitMQ #{plugin_name} plugin" do
|
||||
cwd File.join("", "tmp")
|
||||
user node[:deployment][:user]
|
||||
code <<-EOH
|
||||
cp -f "#{plugin_name}-#{node[:rabbitmq][:version]}.ez" #{File.join(node[:rabbitmq][:path], "plugins")}
|
||||
EOH
|
||||
not_if do
|
||||
::File.exists?(File.join(node[:rabbitmq][:path], "plugins", "#{plugin_name}-#{node[:rabbitmq][:version]}.ez"))
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#
|
||||
# Cookbook Name:: gateway
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2011, VMware
|
||||
#
|
||||
|
||||
cloudfoundry_service "rabbitmq" do
|
||||
components ["rabbitmq_gateway"]
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
#
|
||||
# Cookbook Name:: node
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2011, VMware
|
||||
#
|
||||
|
||||
cloudfoundry_service "rabbitmq" do
|
||||
components ["rabbitmq_node"]
|
||||
end
|
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
cloud_controller_uri: <%= node[:cloud_controller][:service_api_uri] %>
|
||||
service:
|
||||
name: rabbitmq
|
||||
version: "2.4"
|
||||
description: "RabbitMQ message queue"
|
||||
plans: ["free"]
|
||||
tags: ["rabbitmq", "rabitmq-2.4", "message-queue", "amqp"]
|
||||
host: localhost
|
||||
index: 0
|
||||
token: <%= node[:rabbitmq_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/rabbit_gateway.pid
|
||||
logging:
|
||||
level: debug
|
||||
plan_management:
|
||||
plans:
|
||||
free:
|
||||
low_water: 10
|
||||
high_water: 180
|
||||
#allow_over_provisioning: false
|
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
capacity: 100
|
||||
plan: free
|
||||
local_db: sqlite3:/var/vcap/services/rabbit/rabbit_node.db
|
||||
base_dir: /var/vcap/services/rabbit/instances
|
||||
mbus: nats://<%= node[:nats_server][:user] %>:<%= node[:nats_server][:password] %>@<%= node[:nats_server][:host] %>:<%= node[:nats_server][:port] %>/
|
||||
index: <%= node[:rabbitmq_node][:index] %>
|
||||
logging:
|
||||
level: debug
|
||||
pid: /var/vcap/sys/run/rabbit_node.pid
|
||||
node_id: <%= "rabbit_node_free_#{node[:rabbitmq_node][:index]}" %>
|
||||
migration_nfs: /mnt/vcap
|
||||
port_range:
|
||||
first: 10001
|
||||
last: 20000
|
||||
admin_port_range:
|
||||
first: 20001
|
||||
last: 30000
|
||||
max_clients: 1000
|
||||
rabbitmq_log_dir: /var/vcap/services/rabbit/logs
|
||||
rabbitmq_server: <%= File.join(node[:rabbitmq][:path], "sbin", "rabbitmq-server") %>
|
|
@ -20,7 +20,7 @@ class JobManager
|
|||
ACM = "acm"
|
||||
ACMDB = "acmdb"
|
||||
|
||||
SERVICES = ["redis", "mysql", "mongodb", "neo4j"]
|
||||
SERVICES = ["redis", "mysql", "mongodb", "neo4j", "rabbitmq"]
|
||||
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"]}
|
||||
INSTALL_JOB_PROPERTIES = {CC => ["builtin_services"], MYSQL_NODE => ["index"], MONGODB_NODE => ["index"], REDIS_NODE => ["index"], NEO4J_NODE => ["index"], RABBITMQ_NODE => ["index"]}
|
||||
|
||||
# Dependency between JOBS and components that are consumed by "vcap_dev" when cf is started or
|
||||
# stopped
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "rabbitmq_gateway",
|
||||
"override_attributes": {},
|
||||
"json_class": "Chef::Role",
|
||||
"description": "RabbitMQ services gateway",
|
||||
"chef_type": "role",
|
||||
"run_list" : [ "recipe[deployment]",
|
||||
"recipe[essentials]",
|
||||
"recipe[ruby]",
|
||||
"recipe[rabbitmq::gateway]"]
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "redis_node",
|
||||
"override_attributes": {},
|
||||
"json_class": "Chef::Role",
|
||||
"description": "RabbitMQ service node",
|
||||
"chef_type": "role",
|
||||
"run_list" : ["recipe[deployment]",
|
||||
"recipe[essentials]",
|
||||
"recipe[ruby]",
|
||||
"recipe[rabbitmq]",
|
||||
"recipe[rabbitmq::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]
|
||||
%w[cloud_controller dea health_manager router stager acm services/redis services/mysql services/mongodb services/postgresql services/neo4j services/rabbit]
|
||||
end
|
||||
|
||||
def dirs
|
||||
|
|
Загрузка…
Ссылка в новой задаче