Skip to content

Commit 9893886

Browse files
authored
Service Aliases (#129)
* feat: Add services command to list all services. * feat: Add service aliases. * Update aliases, ensure apply to all instances. * add some comments to alias code
1 parent cef3110 commit 9893886

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

streamr-docker-dev/bin.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,27 @@ DOCKER_COMPOSE="docker-compose --ansi never"
2121
# don't start these services unless explicitly started
2222
EXCEPT_SERVICES_DEFAULT=() # array of string e.g. ("a" "b")
2323

24+
# Service Aliases
25+
NODE_NO_STORAGE='broker-node-no-storage-1 broker-node-no-storage-2'
26+
NODE_STORAGE='broker-node-storage-1'
27+
NODES="$NODE_NO_STORAGE $NODE_STORAGE"
28+
TRACKERS='tracker-1 tracker-2 tracker-3'
29+
30+
# swap aliases for full names e.g. trackers = tracker-1 tracker-2 tracker-3
31+
# feel free to add more, just make sure you don't end up using actual service
32+
# names as alias names
33+
expandServiceAliases() {
34+
local names=$1
35+
names="${names//node-no-storage/$NODE_NO_STORAGE}"
36+
names="${names//no-storage-nodes/$NODE_NO_STORAGE}"
37+
names="${names//node-storage/$NODE_STORAGE}"
38+
names="${names//storage-nodes/$NODE_STORAGE}"
39+
names="${names//brokers/$NODES}"
40+
names="${names//nodes/$NODES}" # brokers/nodes sort of interchangeable
41+
names="${names//trackers/$TRACKERS}"
42+
echo "$names"
43+
}
44+
2445
# Execute all commands from the root dir of streamr-docker-dev
2546
cd "$ROOT_DIR" || exit 1
2647

@@ -47,6 +68,10 @@ help() {
4768
"$ORIG_DIRNAME/help_scripts.sh" $SERVICES
4869
}
4970

71+
services() {
72+
$DOCKER_COMPOSE config --services
73+
}
74+
5075
start() {
5176
ip_lines=$(ifconfig | grep -c 10.200.10.1)
5277
if [ "$ip_lines" -eq "0" ]; then
@@ -234,6 +259,10 @@ while [ $# -gt 0 ]; do # if there are arguments
234259
shift
235260
done
236261

262+
EXCEPT_SERVICES_DEFAULT=($(expandServiceAliases "${EXCEPT_SERVICES_DEFAULT[*]}"))
263+
SERVICES=$(expandServiceAliases "$SERVICES")
264+
EXCEPT_SERVICES=($(expandServiceAliases "${EXCEPT_SERVICES[*]}"))
265+
237266
# Populate COMMANDS_TO_RUN by executing the relevant method
238267
case $OPERATION in
239268
"" | help )
@@ -272,6 +301,9 @@ wipe )
272301
factory-reset )
273302
factory-reset
274303
;;
304+
services )
305+
services
306+
;;
275307
* )
276308
help
277309
echo "ERROR: Invalid command: $OPERATION"

streamr-docker-dev/help_scripts.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Commands:
1010
help show this screen
1111
start start services
1212
stop stop services
13+
services list all services
1314
restart stop and start services
1415
wait wait for all health checks to pass
1516
ps list docker containers

0 commit comments

Comments
 (0)