Skip to content

Commit

Permalink
Add waits
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy Paunin committed Oct 25, 2016
1 parent 17cfd1c commit 7a76e5d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 73 deletions.
51 changes: 2 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,9 @@ There are 3 folders.

1. base - the base Dockerfile is based on an Ubuntu image with RabbitMQ installations.
2. server - This builds on the base image and has the startup script for bring up a RabbitMQ server
4. cluster - This contains a https://docs.docker.com/compose/[docker-compose] definition file(docker-compose.yml) for brining up the rabbitmq cluster. Use `docker-compose up -d` to bring up the cluster.
4. cluster - This contains a https://docs.docker.com/compose/[docker-compose] definition file(docker-compose.yml) for brining up the rabbitmq cluster. Use `docker-compose -f docker-compose.yml up` to bring up the cluster.



Running the Cluster:
===============================
Once the images are built, boot up the cluster using the docker-compose.yml configuration provided in cluster folder:

[source]
----
docker-compose up -d
----

By default 3 nodes are started up this way:

[source]
----
rabbit1:
image: relaxart/rabbitmq-server
hostname: rabbit1
ports:
- "5672:5672"
- "15672:15672"

rabbit2:
image: relaxart/rabbitmq-server
hostname: rabbit2
links:
- rabbit1
environment:
- CLUSTERED=true
- CLUSTER_WITH=rabbit1
- RAM_NODE=true
ports:
- "5673:5672"
- "15673:15672"

rabbit3:
image: relaxart/rabbitmq-server
hostname: rabbit3
links:
- rabbit1
- rabbit2
environment:
- CLUSTERED=true
- CLUSTER_WITH=rabbit1
ports:
- "5674:5672"
----

if needed, additional nodes can be added to this file. If the entire cluster comes up, the management console can be accessed at http://<dockerip>:15672
If needed, additional nodes can be added to this file. If the entire cluster comes up, the management console can be accessed at http://<dockerip>:15672

and connection host should look like this: `dockerip:5672,dockerip:5673,dockerip:5674`
10 changes: 0 additions & 10 deletions base/Dockerfile

This file was deleted.

9 changes: 6 additions & 3 deletions cluster/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
rabbit1:
image: relaxart/rabbitmq-server
# image: relaxart/rabbitmq-server
build: ./server
hostname: rabbit1
ports:
- "5672:5672"
- "15672:15672"

rabbit2:
image: relaxart/rabbitmq-server
# image: relaxart/rabbitmq-server
build: ./server
hostname: rabbit2
links:
- rabbit1
Expand All @@ -19,7 +21,8 @@ rabbit2:
- "15673:15672"

rabbit3:
image: relaxart/rabbitmq-server
# image: relaxart/rabbitmq-server
build: ./server
hostname: rabbit3
links:
- rabbit1
Expand Down
16 changes: 14 additions & 2 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
FROM relaxart/rabbitmq-base
MAINTAINER Ilya Isaev [email protected]
FROM ubuntu

RUN apt-get update && \
apt-get install -y wget && \
echo "deb http://www.rabbitmq.com/debian/ testing main" | tee /etc/apt/sources.list.d/rabbitmq.list && \
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | apt-key add - && \
apt-get update && \
apt-get install -y rabbitmq-server && \
/usr/sbin/rabbitmq-plugins enable --offline rabbitmq_management rabbitmq_management_agent rabbitmq_management_visualiser rabbitmq_federation rabbitmq_federation_management

ENV DOCKERIZE_VERSION v0.2.0

ADD rabbitmq.config /etc/rabbitmq/rabbitmq.config
ADD erlang.cookie /var/lib/rabbitmq/.erlang.cookie

RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

RUN chmod u+rw /etc/rabbitmq/rabbitmq.config && \
chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie && \
chmod 400 /var/lib/rabbitmq/.erlang.cookie && \
Expand Down
18 changes: 9 additions & 9 deletions server/run.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/bin/bash

if [ -z "$CLUSTERED" ]; then
# if not clustered then start it normally as if it is a single server
/usr/sbin/rabbitmq-server
/usr/sbin/rabbitmq-server -detached
else
if [ -z "$CLUSTER_WITH" ]; then
# If clustered, but cluster with is not specified then again start normally, could be the first server in the
# cluster
/usr/sbin/rabbitmq-server
/usr/sbin/rabbitmq-server -detached
else
#clean folder with data before joining cluster
rm -rf /var/lib/rabbitmq/*
dockerize -wait tcp://$CLUSTER_WITH:25672 -timeout 250s

/usr/sbin/rabbitmq-server -detached

rabbitmqctl stop_app
if [ -z "$RAM_NODE" ]; then
rabbitmqctl join_cluster rabbit@$CLUSTER_WITH
else
rabbitmqctl join_cluster --ram rabbit@$CLUSTER_WITH
fi
rabbitmqctl start_app

# Tail to keep the a foreground process active..
tail -f /var/log/rabbitmq/rabbit\@$HOSTNAME.log
fi
fi

sleep 60 && echo "Ilya we need to fix logging..."
tail -f /var/log/rabbitmq/*

0 comments on commit 7a76e5d

Please sign in to comment.