File: start

package info (click to toggle)
ruby-redis 5.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,160 kB
  • sloc: ruby: 11,445; makefile: 117; sh: 24
file content (48 lines) | stat: -rwxr-xr-x 1,360 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /usr/bin/env ruby
# frozen_string_literal: true

# This is a helper script used together with examples/sentinel.rb
# It runs two Redis masters, two slaves for each of them, and two sentinels.
# After 30 seconds, the first master dies.
#
# You don't need to run this script yourself. Rather, use examples/sentinel.rb.

require "fileutils"

pids = []

at_exit do
  pids.each do |pid|
    Process.kill(:INT, pid)
  rescue Errno::ESRCH
  end

  Process.waitall
end

base = __dir__

# Masters
pids << spawn("redis-server --port 6380 --loglevel warning")
pids << spawn("redis-server --port 6381 --loglevel warning")

# Slaves of Master 1
pids << spawn("redis-server --port 63800 --slaveof 127.0.0.1 6380 --loglevel warning")
pids << spawn("redis-server --port 63801 --slaveof 127.0.0.1 6380 --loglevel warning")

# Slaves of Master 2
pids << spawn("redis-server --port 63810 --slaveof 127.0.0.1 6381 --loglevel warning")
pids << spawn("redis-server --port 63811 --slaveof 127.0.0.1 6381 --loglevel warning")

FileUtils.cp(File.join(base, "sentinel.conf"), "tmp/sentinel1.conf")
FileUtils.cp(File.join(base, "sentinel.conf"), "tmp/sentinel2.conf")

# Sentinels
pids << spawn("redis-server tmp/sentinel1.conf --sentinel --port 26379")
pids << spawn("redis-server tmp/sentinel2.conf --sentinel --port 26380")

sleep 30

Process.kill(:KILL, pids[0])

Process.waitall