@@ -34,7 +34,7 @@ define ssh_all
3434endef
3535
3636define check_for_errors
37- @if $(FLEETCTL ) list-units | egrep -q "( failed|dead) "; then \
37+ @if $(FLEETCTL ) list-units -no-legend | awk '(($$2 == "launched") && ($$5 == " failed"))' | egrep -q "deis-.+service "; then \
3838 echo "\033[0;31mOne or more services failed! Check which services by running 'make status'\033[0m" ; \
3939 echo "\033[0;31mYou can get detailed output with 'fleetctl status deis-servicename.service'\033[0m" ; \
4040 echo "\033[0;31mThis usually indicates an error with Deis - please open an issue on GitHub or ask for help in IRC\033[0m" ; \
@@ -48,18 +48,23 @@ define deis_units
4848 sed -n 's/\(deis-.*\.service\).*/\1/p' | tr '\n' ' ')
4949endef
5050
51+ define echo_cyan
52+ @echo "\033[0;36m$(subst ",,$(1 ) ) \033[0m"
53+ endef
54+
5155define echo_yellow
5256 @echo "\033[0;33m$(subst ",,$(1 ) ) \033[0m"
5357endef
5458
59+ # TODO: re-evaluate the start order now that we're on fleet 0.3.2.
5560# due to scheduling problems with fleet 0.2.0, start order of components
5661# is fragile. hopefully this can be changed soon...
5762COMPONENTS =builder cache controller database logger registry
5863ALL_COMPONENTS =$(COMPONENTS ) router
5964START_COMPONENTS =registry logger cache database
6065
61- ALL_UNITS = $(foreach C, $(COMPONENTS ) , $(wildcard $(C ) /systemd/* ) )
62- START_UNITS = $(foreach C, $(START_COMPONENTS ) , $(wildcard $(C ) /systemd/* ) )
66+ ALL_UNITS = $(foreach C,$(COMPONENTS ) ,$(wildcard $(C ) /systemd/* ) )
67+ START_UNITS = $(foreach C,$(START_COMPONENTS ) ,$(wildcard $(C ) /systemd/* ) )
6368ROUTER_UNITS = $(shell seq -f "deis-router.% g.service" -s " " $(DEIS_FIRST_ROUTER ) 1 $(DEIS_LAST_ROUTER ) )
6469
6570all : build run
@@ -80,8 +85,17 @@ clean: uninstall
8085full-clean : clean
8186 $(call ssh_all,'for c in $(ALL_COMPONENTS ) ; do docker rmi deis-$$c; done')
8287
83- install : check-fleet
84- $(FLEETCTL ) submit $(START_UNITS )
88+ install : check-fleet install-routers
89+ $(FLEETCTL ) load $(START_UNITS )
90+ $(FLEETCTL ) load controller/systemd/*
91+ $(FLEETCTL ) load builder/systemd/*
92+
93+ install-routers : check-fleet
94+ @$(foreach R, $(ROUTER_UNITS ) , \
95+ cp router/systemd/deis-router.service ./$(R ) ; \
96+ $(FLEETCTL ) load ./$(R ) ; \
97+ rm -f ./$(R ) ; \
98+ )
8599
86100pull :
87101 $(call ssh_all,'for c in $(ALL_COMPONENTS ) ; do docker pull deis/$$c; done')
@@ -91,47 +105,66 @@ restart: stop start
91105
92106run : install start
93107
94- start : check-fleet start-routers
108+ start : check-fleet start-warning start- routers
95109 @# registry logger cache database
96- $(call echo_yellow,"Starting Deis! Deis will be functional once all services are reported as running... ")
97- $(FLEETCTL ) start $(START_UNITS )
98- $(call echo_yellow,"Waiting for deis-registry to start (this can take some time) ... " )
99- @until $(FLEETCTL ) list-units | egrep -q " deis-registry.+(running|failed|dead)" ; do printf " \033[0;33mStatus:\033[0m " ; $(FLEETCTL ) list-units | grep " registry" | awk ' {printf $$3}' ; printf " \r" ; sleep 10; done
110+ $(call echo_yellow,"Waiting for deis-registry to start...")
111+ $(FLEETCTL ) start -no-block $(START_UNITS )
112+ @until $(FLEETCTL ) list-units | egrep -q " deis-registry.+(running)" ; \
113+ do sleep 2; \
114+ printf " \033[0;33mStatus:\033[0m " ; $(FLEETCTL ) list-units | \
115+ grep " deis-registry" | awk ' {printf "%-10s (%s) \r", $$4, $$5}' ; \
116+ sleep 8; \
117+ done
100118 $(call check_for_errors)
101119
102120 @# controller
103- $(call echo_yellow,"Done! Waiting for deis-controller...")
104- $(FLEETCTL) submit controller/systemd/*
105- $(FLEETCTL) start controller/systemd/*
106- @until $(FLEETCTL) list-units | egrep -q "deis-controller.+(running|failed|dead)"; do printf "\033[0;33mStatus:\033[0m "; $(FLEETCTL) list-units | grep "controller" | awk '{printf $$3}'; printf "\r" ; sleep 10; done
121+ $(call echo_yellow,"Waiting for deis-controller to start...")
122+ $(FLEETCTL) start -no-block controller/systemd/*
123+ @until $(FLEETCTL) list-units | egrep -q "deis-controller.+(running)"; \
124+ do sleep 2; \
125+ printf "\033[0;33mStatus:\033[0m "; $(FLEETCTL) list-units | \
126+ grep "deis-controller" | awk '{printf "%-10s (%s) \r", $$4, $$5}'; \
127+ sleep 8; \
128+ done
107129 $(call check_for_errors)
108130
109131 @# builder
110- $(call echo_yellow,"Done! Waiting for deis-builder to start (this can also take some time)... ")
111- $(FLEETCTL) submit builder/systemd/*
112- $(FLEETCTL) start builder/systemd/*
113- @until $(FLEETCTL) list-units | egrep -q "deis-builder.+(running|failed|dead)"; do printf "\033[0;33mStatus:\033[0m "; $(FLEETCTL) list-units | grep "builder" | awk '{printf $$3}'; printf "\r" ; sleep 10; done
132+ $(call echo_yellow,"Waiting for deis-builder to start...")
133+ $(FLEETCTL) start -no-block builder/systemd/*
134+ @until $(FLEETCTL) list-units | egrep -q "deis-builder.+(running)"; \
135+ do sleep 2; \
136+ printf "\033[0;33mStatus:\033[0m "; $(FLEETCTL) list-units | \
137+ grep "deis-builder" | awk '{printf "%-10s (%s) \r", $$4, $$5}'; \
138+ sleep 8; \
139+ done
114140 $(call check_for_errors)
115141
116142 $(call echo_yellow,"Your Deis cluster is ready to go! Continue following the README to login and use Deis.")
117143
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- )
144+ start-routers : check-fleet start-warning
145+ $(call echo_yellow,"Waiting for 1 of $(DEIS_NUM_ROUTERS ) deis-routers to start...")
146+ $(foreach R,$(ROUTER_UNITS ) ,$(FLEETCTL ) start -no-block $(R ) ;)
147+ @until $(FLEETCTL ) list-units | egrep -q " deis-router.+(running)" ; \
148+ do sleep 2; \
149+ printf " \033[0;33mStatus:\033[0m " ; $(FLEETCTL ) list-units | \
150+ grep " deis-router" | head -n 1 | \
151+ awk ' {printf "%-10s (%s) \r", $$4, $$5}' ; \
152+ sleep 8; \
153+ done
154+ $(call check_for_errors)
155+
156+ start-warning :
157+ $(call echo_cyan,"Deis components may take a long time to start the first time they are initialized.")
126158
127159status : check-fleet
128160 $(FLEETCTL ) list-units
129161
130162stop : check-fleet
131- $(FLEETCTL ) stop $( call deis_units,loaded,. )
163+ $(FLEETCTL ) stop -block-attempts=600 $( strip $( call deis_units,launched,active) )
132164
133165tests :
134166 cd test && bundle install && bundle exec rake
135167
136168uninstall : check-fleet stop
137- $(FLEETCTL ) destroy $(call deis_units,loaded,.)
169+ $(FLEETCTL ) unload $(call deis_units,launched,.)
170+ $(FLEETCTL ) destroy $(strip $(call deis_units,.,.) )
0 commit comments