DATAREDIS-315 - Update Makefile to spin up cluster.

Original pull request: #158.
This commit is contained in:
Christoph Strobl
2015-07-28 08:56:31 +02:00
committed by Mark Paluch
parent 4893dc1533
commit a6ab1b53b3

View File

@@ -69,6 +69,48 @@ sentinel-start: work/sentinel-26379.pid work/sentinel-26380.pid work/sentinel-26
sentinel-stop: stop-26379 stop-26380 stop-26381
#########
# Cluster
#########
.PRECIOUS: work/cluster-%.conf
work/cluster-%.conf:
@mkdir -p $(@D)
echo port $* >> $@
echo cluster-enabled yes >> $@
echo cluster-config-file $(shell pwd)/work/nodes-$*.conf >> $@
echo cluster-node-timeout 5 >> $@
echo pidfile $(shell pwd)/work/cluster-$*.pid >> $@
echo logfile $(shell pwd)/work/cluster-$*.log >> $@
echo save \"\" >> $@
work/cluster-%.pid: work/cluster-%.conf work/redis/bin/redis-server
work/redis/bin/redis-server $< &
cluster-start: work/cluster-7379.pid work/cluster-7380.pid work/cluster-7381.pid work/cluster-7382.pid
work/meet-%:
-work/redis/bin/redis-cli -p $* cluster meet 127.0.0.1 7379
# Handled separately because this node is a slave
work/meet-7382:
-work/redis/bin/redis-cli -p 7382 cluster meet 127.0.0.1 7379
sleep 2
-work/redis/bin/redis-cli -p 7382 cluster replicate $(shell work/redis/bin/redis-cli -p 7379 cluster myid)
cluster-meet: work/meet-7380 work/meet-7381 work/meet-7382
cluster-stop: stop-7379 stop-7380 stop-7381 stop-7382
cluster-slots:
-work/redis/bin/redis-cli -p 7379 cluster addslots $(shell seq 0 5460)
-work/redis/bin/redis-cli -p 7380 cluster addslots $(shell seq 5461 10922)
-work/redis/bin/redis-cli -p 7381 cluster addslots $(shell seq 10923 16383)
cluster-init: cluster-start cluster-meet cluster-slots
########
# Global
########
@@ -86,12 +128,12 @@ work/redis/bin/redis-cli work/redis/bin/redis-server:
$(MAKE) -C work/redis-$(REDIS_VERSION) PREFIX=$(shell pwd)/work/redis install
rm -rf work/redis-$(REDIS_VERSION)
start: redis-start sentinel-start
start: redis-start sentinel-start cluster-init
stop-%: work/redis/bin/redis-cli
-work/redis/bin/redis-cli -p $* shutdown
stop: redis-stop sentinel-stop
stop: redis-stop sentinel-stop cluster-stop
test:
$(MAKE) start