Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix the bug that improving the cleanup work when starting rabbitmq in…

…stance timeout

Change-Id: I1c517a436db00bdc2b43dbf653377f98249167cc
  • Loading branch information...
commit ec3334fe5188f33269d96e60ca7db14a31232cee 1 parent 5ee7655
@tangr1 tangr1 authored
View
2  rabbit/bin/rabbit_node
@@ -23,6 +23,8 @@ class VCAP::Services::Rabbit::NodeBin < VCAP::Services::Base::NodeBin
options[:admin_port_range] = parse_property(config, "admin_port_range", Range)
options[:rabbitmq_server] = parse_property(config, "rabbitmq_server", String)
options[:rabbitmq_log_dir] = parse_property(config, "rabbitmq_log_dir", String)
+ options[:rabbitmq_start_timeout] = parse_property(config, "rabbitmq_start_timeout", Integer, :optional => true)
+ puts options[:rabbitmq_start_timeout]
options[:config_template] = File.expand_path("../../resources/rabbitmq.config.erb", __FILE__)
options[:max_clients] = parse_property(config, "max_clients", Integer, :optional => true)
options[:max_memory_factor] = parse_property(config, "max_memory_factor", Float, :optional => true)
View
2  rabbit/config/rabbit_gateway.yml
@@ -6,6 +6,7 @@ service:
description: "RabbitMQ message queue"
plans: ["free"]
tags: ["rabbitmq", "rabitmq-2.4", "message-queue", "amqp"]
+ timeout: 15
ip_route: localhost
#proxy:
# host: proxy
@@ -23,6 +24,7 @@ plan_management:
low_water: 10
high_water: 180
#allow_over_provisioning: false
+node_timeout: 10
# z_interval: 30
# check_orphan_interval: 3600
# double_check_orphan_interval: 300
View
1  rabbit/config/rabbit_node.yml
@@ -21,6 +21,7 @@ admin_port_range:
last: 30000
rabbitmq_server: /home/tangrui/rabbitmq_server-2.4.1/sbin/rabbitmq-server
rabbitmq_log_dir: /var/vcap/sys/log/rabbit
+# rabbitmq_start_timeout: 5
# z_interval: 30
# max_nats_payload: 1048576
# fqdn_hosts: false
View
13 rabbit/lib/rabbit_service/rabbit_node.rb
@@ -92,6 +92,7 @@ def initialize(options)
# Timeout for rabbitmq client operations, node cannot be blocked on any rabbitmq instances.
# Default value is 2 seconds.
@rabbit_timeout = @options[:rabbit_timeout] || 2
+ @rabbitmq_start_timeout = @options[:rabbitmq_start_timeout] || 5
@default_permissions = '{"configure":".*","write":".*","read":".*"}'
@initial_username = "guest"
@initial_password = "guest"
@@ -345,7 +346,10 @@ def save_instance(instance)
end
def destroy_instance(instance)
- raise RabbitError.new(RabbitError::RABBIT_DESTORY_INSTANCE_FAILED, instance.inspect) unless instance.destroy
+ # Here need check whether the object is in db or not,
+ # otherwise the destory operation will persist the object from memory to db without deleting it,
+ # the behavior of datamapper is doing persistent work at the end of each save/update/destroy API
+ raise RabbitError.new(RabbitError::RABBIT_DESTORY_INSTANCE_FAILED, instance.inspect) unless instance.new? || instance.destroy
end
def get_instance(instance_id)
@@ -420,7 +424,7 @@ def start_instance(instance)
Process.detach(pid)
@logger.debug("Service #{instance.name} started with pid #{pid}")
# Wait enough time for the RabbitMQ server starting
- for i in 1..3
+ (1..@rabbitmq_start_timeout).each do
sleep 1
if instance.pid # An existed instance
credentials = {"username" => instance.admin_username, "password" => instance.admin_password, "admin_port" => instance.admin_port}
@@ -436,7 +440,10 @@ def start_instance(instance)
next
end
end
- @logger.error("Timeout to start RabbitMQ server")
+ @logger.error("Timeout to start RabbitMQ server for instance #{instance.name}")
+ # Stop the instance if it is running
+ instance.pid = pid
+ stop_instance(instance) if instance.running?
raise RabbitError.new(RabbitError::RABBIT_START_INSTANCE_FAILED, instance.inspect)
end
Please sign in to comment.
Something went wrong with that request. Please try again.