Skip to content
This repository has been archived by the owner on Jun 1, 2020. It is now read-only.

Add option to run riak as a standalone process (not an runit service) #54

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ RUN \
# Cleanup
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Setup the Riak service
RUN mkdir -p /etc/service/riak
ADD bin/riak.sh /etc/service/riak/run
# Setup runtime riak.conf changes
ADD bin/riak_conf.sh /etc/my_init.d/97_riak_conf.sh

# Setup riak initialization scripts
ADD bin/run_riak.sh /usr/local/bin/run_riak.sh
ADD bin/init_riak.sh /etc/my_init.d/98_riak_init.sh

# Setup automatic clustering
ADD bin/automatic_clustering.sh /etc/my_init.d/99_automatic_clustering.sh
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ $ make build
- `DOCKER_RIAK_BACKEND` - Optional Riak backend to use (default: `bitcask`)
- `DOCKER_RIAK_STRONG_CONSISTENCY` - Enables strong consistency subsystem (values: `on` or `off`, default: `off`)
- `DOCKER_RIAK_SEARCH` - Enables search (values: `on` or `off`, default: `off`)
- `DOCKER_RIAK_SERVICE` - Runs Riak as an runit service (values: `1` or `0`, default: `1`). If `0`, Riak will simply be run as a background process, and will not automatically restart if killed.

### Launch cluster

Expand Down
12 changes: 12 additions & 0 deletions bin/init_riak.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# If riak should be run as an runit service, simply symlink the run script to
# /etc/service/riak/run.
#
# Otherwise, exec riak here in the background.
if env | grep -q "DOCKER_RIAK_SERVICE=1"; then
mkdir -p /etc/service/riak
ln -s /usr/local/bin/run_riak.sh /etc/service/riak/run
else
/usr/local/bin/run_riak.sh &
fi
4 changes: 0 additions & 4 deletions bin/riak.sh → bin/riak_conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,3 @@ sed -i.bak "s/## strong_consistency = \(.*\)/strong_consistency = ${DOCKER_RIAK_

# Ensure the search property is set correctly
sed -i.bak "s/search = \(.*\)/search = ${DOCKER_RIAK_SEARCH}/" /etc/riak/riak.conf

# Start Riak
exec /sbin/setuser riak "$(ls -d /usr/lib/riak/erts*)/bin/run_erl" "/tmp/riak" \
"/var/log/riak" "exec /usr/sbin/riak console"
5 changes: 5 additions & 0 deletions bin/run_riak.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

# Start Riak
exec /sbin/setuser riak "$(ls -d /usr/lib/riak/erts*)/bin/run_erl" "/tmp/riak" \
"/var/log/riak" "exec /usr/sbin/riak console"
3 changes: 3 additions & 0 deletions bin/start-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function start_new_riak_cluter {
-e "DOCKER_RIAK_BACKEND=${DOCKER_RIAK_BACKEND}" \
-e "DOCKER_RIAK_STRONG_CONSISTENCY=${DOCKER_RIAK_STRONG_CONSISTENCY}" \
-e "DOCKER_RIAK_SEARCH=${DOCKER_RIAK_SEARCH}" \
-e "DOCKER_RIAK_SERVICE=${DOCKER_RIAK_SERVICE}" \
-p $publish_http_port \
-p $publish_pb_port \
--link "riak01:seed" \
Expand All @@ -66,6 +67,7 @@ function start_new_riak_cluter {
-e "DOCKER_RIAK_BACKEND=${DOCKER_RIAK_BACKEND}" \
-e "DOCKER_RIAK_STRONG_CONSISTENCY=${DOCKER_RIAK_STRONG_CONSISTENCY}" \
-e "DOCKER_RIAK_SEARCH=${DOCKER_RIAK_SEARCH}" \
-e "DOCKER_RIAK_SERVICE=${DOCKER_RIAK_SERVICE}" \
-p $publish_http_port \
-p $publish_pb_port \
--name "riak${index}" \
Expand Down Expand Up @@ -110,6 +112,7 @@ DOCKER_RIAK_CLUSTER_SIZE=${DOCKER_RIAK_CLUSTER_SIZE:-5}
DOCKER_RIAK_BACKEND=${DOCKER_RIAK_BACKEND:-bitcask}
DOCKER_RIAK_STRONG_CONSISTENCY=${DOCKER_RIAK_STRONG_CONSISTENCY:-off}
DOCKER_RIAK_SEARCH=${DOCKER_RIAK_SEARCH:-off}
DOCKER_RIAK_SERVICE=${DOCKER_RIAK_SERVICE:-1}

if docker ps -a | grep "hectcastro/riak" >/dev/null; then
echo ""
Expand Down