Skip to content
Snippets Groups Projects
Commit be3f7683 authored by Alexey Golubev's avatar Alexey Golubev
Browse files

Changed rabbitmq settings

parent daa1850e
No related branches found
No related tags found
No related merge requests found
...@@ -153,9 +153,7 @@ Below is the complete list of parameters that can be set using environment varia ...@@ -153,9 +153,7 @@ Below is the complete list of parameters that can be set using environment varia
- **POSTGRESQL_SERVER_DB_NAME**: The name of a PostgreSQL database to be created on the image startup. - **POSTGRESQL_SERVER_DB_NAME**: The name of a PostgreSQL database to be created on the image startup.
- **POSTGRESQL_SERVER_USER**: The new user name with superuser permissions for the PostgreSQL account. - **POSTGRESQL_SERVER_USER**: The new user name with superuser permissions for the PostgreSQL account.
- **POSTGRESQL_SERVER_PASS**: The password set for the PostgreSQL account. - **POSTGRESQL_SERVER_PASS**: The password set for the PostgreSQL account.
- **RABBITMQ_SERVER_HOST**: The IP address or the name of the host where the RabbitMQ server is running. - **RABBITMQ_SERVER_URL**: The [AMQP URL](http://www.rabbitmq.com/uri-spec.html "RabbitMQ URI Specification") to connect to RabbitMQ server.
- **RABBITMQ_SERVER_USER**: The RabbitMQ server user name.
- **RABBITMQ_SERVER_PASS**: The password set for the RabbitMQ account.
- **REDIS_SERVER_HOST**: The IP address or the name of the host where the Redis server is running. - **REDIS_SERVER_HOST**: The IP address or the name of the host where the Redis server is running.
- **REDIS_SERVER_PORT**: The Redis server port number. - **REDIS_SERVER_PORT**: The Redis server port number.
......
...@@ -9,9 +9,7 @@ services: ...@@ -9,9 +9,7 @@ services:
- POSTGRESQL_SERVER_PORT=5432 - POSTGRESQL_SERVER_PORT=5432
- POSTGRESQL_SERVER_DB_NAME=onlyoffice - POSTGRESQL_SERVER_DB_NAME=onlyoffice
- POSTGRESQL_SERVER_USER=onlyoffice - POSTGRESQL_SERVER_USER=onlyoffice
- RABBITMQ_SERVER_HOST=onlyoffice-rabbitmq - RABBITMQ_SERVER_URL=amqp://guest:guest@onlyoffice-rabbitmq
- RABBITMQ_SERVER_USER=guest
- RABBITMQ_SERVER_PASS=guest
- REDIS_SERVER_HOST=onlyoffice-redis - REDIS_SERVER_HOST=onlyoffice-redis
- REDIS_SERVER_PORT=6379 - REDIS_SERVER_PORT=6379
stdin_open: true stdin_open: true
......
...@@ -37,16 +37,55 @@ read_setting(){ ...@@ -37,16 +37,55 @@ read_setting(){
POSTGRESQL_SERVER_USER=${POSTGRESQL_SERVER_USER:-$(${JSON} services.CoAuthoring.sql.dbUser)} POSTGRESQL_SERVER_USER=${POSTGRESQL_SERVER_USER:-$(${JSON} services.CoAuthoring.sql.dbUser)}
POSTGRESQL_SERVER_PASS=${POSTGRESQL_SERVER_PASS:-$(${JSON} services.CoAuthoring.sql.dbPass)} POSTGRESQL_SERVER_PASS=${POSTGRESQL_SERVER_PASS:-$(${JSON} services.CoAuthoring.sql.dbPass)}
RABBITMQ_SERVER_URL=$(${JSON} rabbitmq.url) RABBITMQ_SERVER_URL=${RABBITMQ_SERVER_URL:-$(${JSON} rabbitmq.url)}
RABBITMQ_SERVER_HOST=${RABBITMQ_SERVER_HOST:-${RABBITMQ_SERVER_URL#'amqp://'}} parse_rabbitmq_url
RABBITMQ_SERVER_USER=${RABBITMQ_SERVER_USER:-$(${JSON} rabbitmq.login)}
RABBITMQ_SERVER_PASS=${RABBITMQ_SERVER_PASS:-$(${JSON} rabbitmq.password)}
RABBITMQ_SERVER_PORT=${RABBITMQ_SERVER_PORT:-"5672"}
REDIS_SERVER_HOST=${REDIS_SERVER_HOST:-$(${JSON} services.CoAuthoring.redis.host)} REDIS_SERVER_HOST=${REDIS_SERVER_HOST:-$(${JSON} services.CoAuthoring.redis.host)}
REDIS_SERVER_PORT=${REDIS_SERVER_PORT:-$(${JSON} services.CoAuthoring.redis.port)} REDIS_SERVER_PORT=${REDIS_SERVER_PORT:-$(${JSON} services.CoAuthoring.redis.port)}
} }
parse_rabbitmq_url(){
local amqp=${RABBITMQ_SERVER_URL}
# extract the protocol
local proto="$(echo $amqp | grep :// | sed -e's,^\(.*://\).*,\1,g')"
# remove the protocol
local url="$(echo ${amqp/$proto/})"
# extract the user and password (if any)
local userpass="`echo $url | grep @ | cut -d@ -f1`"
local pass=`echo $userpass | grep : | cut -d: -f2`
local user
if [ -n "$pass" ]; then
user=`echo $userpass | grep : | cut -d: -f1`
else
user=$userpass
fi
echo $user
# extract the host
local hostport="$(echo ${url/$userpass@/} | cut -d/ -f1)"
# by request - try to extract the port
local port="$(echo $hostport | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')"
local host
if [ -n "$port" ]; then
host=`echo $hostport | grep : | cut -d: -f1`
else
host=$hostport
port="5672"
fi
# extract the path (if any)
local path="$(echo $url | grep / | cut -d/ -f2-)"
RABBITMQ_SERVER_HOST=$host
RABBITMQ_SERVER_USER=$user
RABBITMQ_SERVER_PASS=$pass
RABBITMQ_SERVER_PORT=$port
}
waiting_for_connection(){ waiting_for_connection(){
until nc -z -w 3 "$1" "$2"; do until nc -z -w 3 "$1" "$2"; do
>&2 echo "Waiting for connection to the $1 host on port $2" >&2 echo "Waiting for connection to the $1 host on port $2"
...@@ -77,9 +116,7 @@ update_postgresql_settings(){ ...@@ -77,9 +116,7 @@ update_postgresql_settings(){
} }
update_rabbitmq_setting(){ update_rabbitmq_setting(){
${JSON} -I -e "this.rabbitmq.url = 'amqp://${RABBITMQ_SERVER_HOST}'" ${JSON} -I -e "this.rabbitmq.url = '${RABBITMQ_SERVER_URL}'"
${JSON} -I -e "this.rabbitmq.login = '${RABBITMQ_SERVER_USER}'"
${JSON} -I -e "this.rabbitmq.password = '${RABBITMQ_SERVER_PASS}'"
} }
update_redis_settings(){ update_redis_settings(){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment