@@ -33,6 +33,25 @@ if {[catch {cd tmp}]} {
33
33
exit 1
34
34
}
35
35
36
+ # Execute the specified instance of the server specified by 'type', using
37
+ # the provided configuration file. Returns the PID of the process.
38
+ proc exec_instance {type cfgfile} {
39
+ if {$type eq " redis" } {
40
+ set prgname redis-server
41
+ } elseif {$type eq " sentinel" } {
42
+ set prgname redis-sentinel
43
+ } else {
44
+ error " Unknown instance type."
45
+ }
46
+
47
+ if {$::valgrind } {
48
+ set pid [exec valgrind --track-origins=yes --suppressions=../../../src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full ../../../src/${prgname} $cfgfile &]
49
+ } else {
50
+ set pid [exec ../../../src/${prgname} $cfgfile &]
51
+ }
52
+ return $pid
53
+ }
54
+
36
55
# Spawn a redis or sentinel instance, depending on 'type'.
37
56
proc spawn_instance {type base_port count {conf {}}} {
38
57
for {set j 0} {$j < $count } {incr j} {
@@ -59,20 +78,7 @@ proc spawn_instance {type base_port count {conf {}}} {
59
78
close $cfg
60
79
61
80
# Finally exec it and remember the pid for later cleanup.
62
- if {$type eq " redis" } {
63
- set prgname redis-server
64
- } elseif {$type eq " sentinel" } {
65
- set prgname redis-sentinel
66
- } else {
67
- error " Unknown instance type."
68
- }
69
-
70
- if {$::valgrind } {
71
- set pid [exec valgrind --track-origins=yes --suppressions=../../../src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full ../../../src/${prgname} $cfgfile &]
72
- } else {
73
- set pid [exec ../../../src/${prgname} $cfgfile &]
74
- }
75
-
81
+ set pid [exec_instance $type $cfgfile ]
76
82
lappend ::pids $pid
77
83
78
84
# Check availability
@@ -411,18 +417,7 @@ proc restart_instance {type id} {
411
417
412
418
# Execute the instance with its old setup and append the new pid
413
419
# file for cleanup.
414
- if {$type eq " redis" } {
415
- set prgname redis-server
416
- } else {
417
- set prgname redis-sentinel
418
- }
419
-
420
- if {$::valgrind } {
421
- set pid [exec valgrind --track-origins=yes --suppressions=../../../src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full ../../../src/${prgname} $cfgfile &]
422
- } else {
423
- set pid [exec ../../../src/${prgname} $cfgfile &]
424
- }
425
-
420
+ set pid [exec_instance $type $cfgfile ]
426
421
set_instance_attrib $type $id pid $pid
427
422
lappend ::pids $pid
428
423
0 commit comments