Skip to content

Commit 52b93ac

Browse files
committed
fix(Makefile): update to work with fleetctl 0.3.2
1 parent 369c2f4 commit 52b93ac

1 file changed

Lines changed: 60 additions & 28 deletions

File tree

Makefile

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ define ssh_all
3434
endef
3535

3636
define 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,6 +48,10 @@ define deis_units
4848
sed -n 's/\(deis-.*\.service\).*/\1/p' | tr '\n' ' ')
4949
endef
5050

51+
define echo_cyan
52+
@echo "\033[0;36m$(subst ",,$(1))\033[0m"
53+
endef
54+
5155
define echo_yellow
5256
@echo "\033[0;33m$(subst ",,$(1))\033[0m"
5357
endef
@@ -59,8 +63,8 @@ COMPONENTS=builder cache controller database logger registry
5963
ALL_COMPONENTS=$(COMPONENTS) router
6064
START_COMPONENTS=registry logger cache database
6165

62-
ALL_UNITS = $(foreach C, $(COMPONENTS), $(wildcard $(C)/systemd/*))
63-
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/*))
6468
ROUTER_UNITS = $(shell seq -f "deis-router.%g.service" -s " " $(DEIS_FIRST_ROUTER) 1 $(DEIS_LAST_ROUTER))
6569

6670
all: build run
@@ -81,8 +85,17 @@ clean: uninstall
8185
full-clean: clean
8286
$(call ssh_all,'for c in $(ALL_COMPONENTS); do docker rmi deis-$$c; done')
8387

84-
install: check-fleet
85-
$(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+
)
8699

87100
pull:
88101
$(call ssh_all,'for c in $(ALL_COMPONENTS); do docker pull deis/$$c; done')
@@ -92,47 +105,66 @@ restart: stop start
92105

93106
run: install start
94107

95-
start: check-fleet start-routers
108+
start: check-fleet start-warning start-routers
96109
@# registry logger cache database
97-
$(call echo_yellow,"Starting Deis! Deis will be functional once all services are reported as running... ")
98-
$(FLEETCTL) start $(START_UNITS)
99-
$(call echo_yellow,"Waiting for deis-registry to start (this can take some time)... ")
100-
@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
101118
$(call check_for_errors)
102119

103120
@# controller
104-
$(call echo_yellow,"Done! Waiting for deis-controller...")
105-
$(FLEETCTL) submit controller/systemd/*
106-
$(FLEETCTL) start controller/systemd/*
107-
@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
108129
$(call check_for_errors)
109130

110131
@# builder
111-
$(call echo_yellow,"Done! Waiting for deis-builder to start (this can also take some time)... ")
112-
$(FLEETCTL) submit builder/systemd/*
113-
$(FLEETCTL) start builder/systemd/*
114-
@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
115140
$(call check_for_errors)
116141

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

119-
start-routers:
120-
$(call echo_yellow,"Starting $(DEIS_NUM_ROUTERS) router(s)...")
121-
@ $(foreach U, $(ROUTER_UNITS), \
122-
cp router/systemd/deis-router.service ./$(U) ; \
123-
$(FLEETCTL) submit ./$(U) ; \
124-
$(FLEETCTL) start ./$(U) ; \
125-
rm -f ./$(U) ; \
126-
)
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.")
127158

128159
status: check-fleet
129160
$(FLEETCTL) list-units
130161

131162
stop: check-fleet
132-
$(FLEETCTL) stop $(call deis_units,loaded,.)
163+
$(FLEETCTL) stop -block-attempts=600 $(strip $(call deis_units,launched,active))
133164

134165
tests:
135166
cd test && bundle install && bundle exec rake
136167

137168
uninstall: check-fleet stop
138-
$(FLEETCTL) destroy $(call deis_units,loaded,.)
169+
$(FLEETCTL) unload $(call deis_units,launched,.)
170+
$(FLEETCTL) destroy $(strip $(call deis_units,.,.))

0 commit comments

Comments
 (0)