Skip to content

Commit a18cca8

Browse files
committed
Fix pid management and paths in Sentinel example.
1 parent 466ccdf commit a18cca8

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

examples/sentinel/sentinel.conf

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1+
sentinel monitor master1 127.0.0.1 6380 2
12
sentinel monitor master2 127.0.0.1 6381 2
2-
sentinel down-after-milliseconds master2 10000
3-
sentinel parallel-syncs master2 5
4-
sentinel config-epoch master2 0
5-
6-
sentinel leader-epoch master2 0
7-
sentinel known-slave master2 127.0.0.1 63810
8-
sentinel known-slave master2 127.0.0.1 63801
9-
sentinel known-sentinel master2 127.0.0.1 26379 d2ea5375967f2b992955679c5832f0c779f50171

examples/sentinel/start

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
11
#! /usr/bin/env ruby
22

3+
require "fileutils"
4+
5+
$pids = []
6+
37
at_exit do
4-
pids.each do |pid|
8+
$pids.each do |pid|
59
Process.kill(:INT, pid)
610
end
711

812
Process.waitall
913
end
1014

11-
pids = []
15+
base = File.expand_path(File.dirname(__FILE__))
1216

1317
# Masters
14-
pids << spawn("redis-server --port 6380")
15-
pids << spawn("redis-server --port 6381")
18+
$pids << spawn("redis-server --port 6380")
19+
$pids << spawn("redis-server --port 6381")
1620

1721
# Slaves of Master 1
18-
pids << spawn("redis-server --port 63800 --slaveof 127.0.0.1 6380")
19-
pids << spawn("redis-server --port 63801 --slaveof 127.0.0.1 6380")
22+
$pids << spawn("redis-server --port 63800 --slaveof 127.0.0.1 6380")
23+
$pids << spawn("redis-server --port 63801 --slaveof 127.0.0.1 6380")
2024

2125
# Slaves of Master 2
22-
pids << spawn("redis-server --port 63810 --slaveof 127.0.0.1 6381")
23-
pids << spawn("redis-server --port 63811 --slaveof 127.0.0.1 6381")
26+
$pids << spawn("redis-server --port 63810 --slaveof 127.0.0.1 6381")
27+
$pids << spawn("redis-server --port 63811 --slaveof 127.0.0.1 6381")
28+
29+
FileUtils.cp(File.join(base, "sentinel.conf"), "tmp/sentinel1.conf")
30+
FileUtils.cp(File.join(base, "sentinel.conf"), "tmp/sentinel2.conf")
2431

2532
# Sentinels
26-
pids << spawn("redis-server sentinel/sentinel.conf --sentinel --port 26379")
27-
pids << spawn("redis-server sentinel/sentinel.conf --sentinel --port 26380")
33+
$pids << spawn("redis-server tmp/sentinel1.conf --sentinel --port 26379")
34+
$pids << spawn("redis-server tmp/sentinel2.conf --sentinel --port 26380")
2835

2936
Process.waitall

0 commit comments

Comments
 (0)