Skip to content

Commit 5110e55

Browse files
committed
refactor(Makefile): enumerate ROUTER_UNITS as a string
Using $foreach over the list of `ROUTER_UNITS` seems cleaner than shell looping by incrementing a counter. This does require the use of the Unix `bc` and `seq` utilities, which should be ubiquitous.
1 parent 3378532 commit 5110e55

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

Makefile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ ifndef DEIS_FIRST_ROUTER
2222
DEIS_FIRST_ROUTER = 1
2323
endif
2424

25+
DEIS_LAST_ROUTER = $(shell echo $(DEIS_FIRST_ROUTER)\+$(DEIS_NUM_ROUTERS)\-1 | bc)
26+
2527
# TODO refactor to support non-vagrant installations, since this Makefile
2628
# is now used by the various contrib/ scripts.
2729
define ssh_all
@@ -51,6 +53,7 @@ START_COMPONENTS=registry logger cache database
5153

5254
ALL_UNITS = $(foreach C, $(ALL_COMPONENTS), $(wildcard $(C)/systemd/*))
5355
START_UNITS = $(foreach C, $(START_COMPONENTS), $(wildcard $(C)/systemd/*))
56+
ROUTER_UNITS = $(shell seq -f "deis-router.%g" -s " " $(DEIS_FIRST_ROUTER) 1 $(DEIS_LAST_ROUTER))
5457

5558
all: build run
5659

@@ -79,21 +82,9 @@ pull:
7982

8083
restart: stop start
8184

82-
routers:
83-
$(call echo_yellow,"Starting $(DEIS_NUM_ROUTERS) router(s)...")
84-
@router_num=$(DEIS_FIRST_ROUTER) ; \
85-
i=1 ; while [ $$i -le $(DEIS_NUM_ROUTERS) ] ; do \
86-
cp router/systemd/deis-router.service ./deis-router.$$router_num.service ; \
87-
$(FLEETCTL) submit ./deis-router.$$router_num.service ; \
88-
$(FLEETCTL) start ./deis-router.$$router_num.service ; \
89-
rm -f ./deis-router.$$router_num.service ; \
90-
i=`expr $$i + 1` ; \
91-
router_num=`expr $$router_num + 1` ; \
92-
done
93-
9485
run: install start
9586

96-
start: check-fleet routers
87+
start: check-fleet start-routers
9788
@# registry logger cache database
9889
$(call echo_yellow,"Starting Deis! Deis will be functional once all services are reported as running... ")
9990
$(FLEETCTL) start $(START_UNITS)
@@ -117,6 +108,15 @@ start: check-fleet routers
117108

118109
$(call echo_yellow,"Your Deis cluster is ready to go! Continue following the README to login and use Deis.")
119110

111+
start-routers:
112+
$(call echo_yellow,"Starting $(DEIS_NUM_ROUTERS) router(s)...")
113+
@ $(foreach C, $(ROUTER_UNITS), \
114+
cp router/systemd/deis-router.service ./$(C).service ; \
115+
fleetctl --strict-host-key-checking=false submit ./$(C).service ; \
116+
fleetctl --strict-host-key-checking=false start ./$(C).service ; \
117+
rm -f ./$(C).service ; \
118+
)
119+
120120
status: check-fleet
121121
$(FLEETCTL) list-units
122122

0 commit comments

Comments
 (0)