@@ -22,6 +22,8 @@ ifndef DEIS_FIRST_ROUTER
2222 DEIS_FIRST_ROUTER = 1
2323endif
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.
2729define ssh_all
@@ -40,17 +42,25 @@ define check_for_errors
4042 fi
4143endef
4244
45+ define deis_units
46+ $(shell $(FLEETCTL ) list-units -no-legend=true | \
47+ awk '($$2 ~ "$(1 ) " && ($$4 ~ "$(2 ) ") )' | \
48+ sed -n 's/\(deis-.*\.service\).*/\1/p' | tr '\n' ' ')
49+ endef
50+
4351define echo_yellow
4452 @echo "\033[0;33m$(subst ",,$(1 ) ) \033[0m"
4553endef
4654
4755# due to scheduling problems with fleet 0.2.0, start order of components
4856# is fragile. hopefully this can be changed soon...
49- ALL_COMPONENTS =builder cache controller database logger registry
57+ COMPONENTS =builder cache controller database logger registry
58+ ALL_COMPONENTS =$(COMPONENTS ) router
5059START_COMPONENTS =registry logger cache database
5160
52- ALL_UNITS = $(foreach C, $(ALL_COMPONENTS ) , $(wildcard $(C ) /systemd/* ) )
61+ ALL_UNITS = $(foreach C, $(COMPONENTS ) , $(wildcard $(C ) /systemd/* ) )
5362START_UNITS = $(foreach C, $(START_COMPONENTS ) , $(wildcard $(C ) /systemd/* ) )
63+ ROUTER_UNITS = $(shell seq -f "deis-router.% g.service" -s " " $(DEIS_FIRST_ROUTER ) 1 $(DEIS_LAST_ROUTER ) )
5464
5565all : build run
5666
7989
8090restart : stop start
8191
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-
9492run : install start
9593
96- start : check-fleet routers
94+ start : check-fleet start- routers
9795 @# registry logger cache database
9896 $(call echo_yellow,"Starting Deis! Deis will be functional once all services are reported as running... ")
9997 $(FLEETCTL ) start $(START_UNITS )
@@ -117,14 +115,23 @@ start: check-fleet routers
117115
118116 $(call echo_yellow,"Your Deis cluster is ready to go! Continue following the README to login and use Deis.")
119117
118+ start-routers :
119+ $(call echo_yellow,"Starting $(DEIS_NUM_ROUTERS ) router(s) ..." )
120+ @ $(foreach U, $(ROUTER_UNITS ) , \
121+ cp router/systemd/deis-router.service ./$(U ) ; \
122+ $(FLEETCTL ) submit ./$(U ) ; \
123+ $(FLEETCTL ) start ./$(U ) ; \
124+ rm -f ./$(U ) ; \
125+ )
126+
120127status : check-fleet
121128 $(FLEETCTL ) list-units
122129
123130stop : check-fleet
124- $(FLEETCTL ) stop $(ALL_UNITS )
131+ $(FLEETCTL ) stop $(call deis_units,loaded,. )
125132
126133tests :
127134 cd test && bundle install && bundle exec rake
128135
129136uninstall : check-fleet stop
130- $(FLEETCTL ) destroy $(ALL_UNITS )
137+ $(FLEETCTL ) destroy $(call deis_units,loaded,. )
0 commit comments