44
55include includes.mk
66
7- define check_for_errors
8- @if $(FLEETCTL ) list-units -no-legend | awk '($$4 == "failed")' | egrep -q "deis-.+service"; then \
9- echo "\033[0;31mOne or more services failed! Check which services by running 'make status'\033[0m" ; \
10- echo "\033[0;31mYou can get detailed output with 'fleetctl status deis-servicename.service'\033[0m" ; \
11- echo "\033[0;31mThis usually indicates an error with Deis - please open an issue on GitHub or ask for help in IRC\033[0m" ; \
12- exit 1 ; \
13- fi
14- endef
15-
16- define deis_units
17- $(shell $(FLEETCTL ) list-units -no-legend=true | \
18- awk '($$4 ~ "$(1 ) ") ' | \
19- sed -n 's/\(deis-.*\.service\).*/\1/p' | tr '\n' ' ')
20- endef
21-
22- # TODO: re-evaluate the fragile start order
23- COMPONENTS =builder cache controller database logger registry
24- ALL_COMPONENTS =$(COMPONENTS ) router
25- START_COMPONENTS =logger cache database
26-
27- ALL_UNITS = $(foreach C,$(COMPONENTS ) ,$(wildcard $(C ) /systemd/* .service) )
28- START_UNITS = $(foreach C,$(START_COMPONENTS ) ,$(wildcard $(C ) /systemd/* .service) )
29-
30- DATA_CONTAINER_TEMPLATES =builder/systemd/deis-builder-data.service database/systemd/deis-database-data.service logger/systemd/deis-logger-data.service registry/systemd/deis-registry-data.service
7+ COMPONENTS =builder cache controller database logger registry router
8+ START_ORDER =logger database cache registry controller builder router
319
3210all : build run
3311
34- build : rsync
35- $(call ssh_all,'cd share && for c in $(ALL_COMPONENTS ) ; do cd $$c && docker build -t deis/$$c . && cd ..; done')
36-
37- clean : uninstall
38- $(call ssh_all,'for c in $(ALL_COMPONENTS ) ; do docker rm -f deis-$$c; done')
39-
40- full-clean : clean
41- $(call ssh_all,'for c in $(ALL_COMPONENTS ) ; do docker rmi deis-$$c; done')
42-
43- install : check-fleet install-routers install-data-containers
44- $(FLEETCTL ) load $(START_UNITS )
45- $(FLEETCTL ) load registry/systemd/* .service
46- $(FLEETCTL ) load controller/systemd/* .service
47- $(FLEETCTL ) load builder/systemd/* .service
48-
49- install-data-containers : check-fleet
50- @$(foreach T, $(DATA_CONTAINER_TEMPLATES ) , \
51- UNIT=` basename $( T) ` ; \
52- EXISTS=` $( FLEETCTL) list-units | grep $$ UNIT` ; \
53- if [ " $$ EXISTS" != " " ]; then \
54- echo $$ UNIT already loaded. Skipping... ; \
55- else \
56- cp $(T ) .template . ; \
57- NEW_FILENAME=` ls * .template | sed ' s/\.template//g' ` ; \
58- mv * .template $$ NEW_FILENAME ; \
59- MACHINE_ID=` $( FLEETCTL) list-machines --no-legend --full | awk ' BEGIN { OFS="\t"; srand() } { print rand(), $$1 }' | sort -n | cut -f2- | head -1` ; \
60- sed -e " s/CHANGEME/$$ MACHINE_ID/" $$ NEW_FILENAME > $$ NEW_FILENAME.bak ; \
61- rm -f $$ NEW_FILENAME ; \
62- mv $$ NEW_FILENAME.bak $$ NEW_FILENAME ; \
63- $(FLEETCTL ) load $$ NEW_FILENAME ; \
64- rm -f $$ NEW_FILENAME ; \
65- fi ; \
66- )
12+ dev-registry : check-docker
13+ @# pull registry image if it doesn't already exist
14+ @docker history registry:0.8.1 > /dev/null 2>&1 || docker pull registry:0.8.1
6715
68- install-routers : check-fleet
69- @$(foreach R, $(ROUTER_UNITS ) , \
70- $(FLEETCTL ) load router/systemd/$(R ) ; \
71- )
16+ @# run registry container if it doesn't already exist
17+ @docker inspect registry >/dev/null 2>&1 || docker run -d -p 5000:5000 --name registry registry:0.8.1
7218
73- pull :
74- $( call ssh_all,'for c in $( ALL_COMPONENTS ) ; do docker pull deis/$$c:latest; done')
75- $( call ssh_all,'docker pull deis/slugrunner:latest')
19+ @echo
20+ @echo "To configure the registry for local Deis development:"
21+ @echo " export DEIS_REGISTRY=`boot2docker ip 2>/dev/null`:5000"
7622
77- restart : stop start
23+ build : check-docker
24+ @$(foreach C, $(COMPONENTS ) , $(MAKE ) -C $(C ) build ;)
7825
79- rsync :
80- $( call rsync_all )
26+ push : check-docker check-registry
27+ @ $( foreach C, $( COMPONENTS ) , $( MAKE ) -C $( C ) push ; )
8128
82- run : install start
29+ full-clean :
30+ @$(foreach C, $(COMPONENTS ) , $(MAKE ) -C $(C ) full-clean ;)
31+
32+ install :
33+ @$(foreach C, $(START_ORDER ) , $(MAKE ) -C $(C ) install ;)
34+
35+ uninstall :
36+ @$(foreach C, $(COMPONENTS ) , $(MAKE ) -C $(C ) uninstall ;)
8337
84- start : check-fleet start-warning start-routers
85- @# logger cache database
86- $(call echo_yellow,"Waiting for deis-cache to start...")
87- $(FLEETCTL ) start -no-block $(START_UNITS )
88- @until $(FLEETCTL ) list-units | egrep -q " deis-cache\..+(running|failed)" ; \
89- do sleep 2; \
90- printf " \033[0;33mStatus:\033[0m " ; $(FLEETCTL ) list-units | \
91- grep " deis-cache\." | awk ' {printf "%-10s (%s) \r", $$3, $$4}' ; \
92- sleep 8; \
93- done
94- $(call check_for_errors)
95-
96- @# registry
97- $(call echo_yellow,"Waiting for deis-registry to start...")
98- $(FLEETCTL) start -no-block registry/systemd/*.service
99- @until $(FLEETCTL) list-units | egrep -q "deis-registry\..+(running|failed)"; \
100- do sleep 2; \
101- printf "\033[0;33mStatus:\033[0m "; $(FLEETCTL) list-units | \
102- grep "deis-registry\." | awk '{printf "%-10s (%s) \r", $$3, $$4}'; \
103- sleep 8; \
104- done
105- $(call check_for_errors)
106-
107- @# controller
108- $(call echo_yellow,"Waiting for deis-controller to start...")
109- $(FLEETCTL) start -no-block controller/systemd/*.service
110- @until $(FLEETCTL) list-units | egrep -q "deis-controller\..+(running|failed)"; \
111- do sleep 2; \
112- printf "\033[0;33mStatus:\033[0m "; $(FLEETCTL) list-units | \
113- grep "deis-controller\." | awk '{printf "%-10s (%s) \r", $$3, $$4}'; \
114- sleep 8; \
115- done
116- $(call check_for_errors)
117-
118- @# builder
119- $(call echo_yellow,"Waiting for deis-builder to start...")
120- $(FLEETCTL) start -no-block builder/systemd/*.service
121- @until $(FLEETCTL) list-units | egrep -q "deis-builder\..+(running|failed)"; \
122- do sleep 2; \
123- printf "\033[0;33mStatus:\033[0m "; $(FLEETCTL) list-units | \
124- grep "deis-builder\." | awk '{printf "%-10s (%s) \r", $$3, $$4}'; \
125- sleep 8; \
126- done
127- $(call check_for_errors)
128-
129- $(call echo_yellow,"Your Deis cluster is ready to go! Continue following the README to login and use Deis.")
130-
131- start-routers : check-fleet start-warning
132- $(call echo_yellow,"Waiting for 1 of $(DEIS_NUM_ROUTERS ) deis-routers to start...")
133- $(foreach R,$(ROUTER_UNITS ) ,$(FLEETCTL ) start -no-block $(R ) ;)
134- @until $(FLEETCTL ) list-units | egrep -q " deis-router.+(running)" ; \
135- do sleep 2; \
136- printf " \033[0;33mStatus:\033[0m " ; $(FLEETCTL ) list-units | \
137- grep " deis-router" | head -n 1 | \
138- awk ' {printf "%-10s (%s) \r", $$3, $$4}' ; \
139- sleep 8; \
140- done
141- $(call check_for_errors)
142-
143- start-warning :
144- $(call echo_cyan,"Deis components may take a long time to start the first time they are initialized.")
145-
146- status : check-fleet
147- $(FLEETCTL ) list-units
148-
149- stop : check-fleet
150- $(FLEETCTL ) stop -block-attempts=600 $(strip $(call deis_units,active) )
38+ start :
39+ @$(foreach C, $(START_ORDER ) , $(MAKE ) -C $(C ) start ;)
40+
41+ stop :
42+ @$(foreach C, $(COMPONENTS ) , $(MAKE ) -C $(C ) stop ;)
43+
44+ restart : stop start
45+
46+ run : install start
15147
15248test : test-components test-integration
15349
15450test-components :
155- @$(foreach C,$(ALL_COMPONENTS ) , \
51+ @$(foreach C,$(COMPONENTS ) , \
15652 echo \\ nTesting deis/$(C ) ; \
15753 $(MAKE ) -C $(C ) test ; \
15854 )
@@ -162,7 +58,3 @@ test-integration:
16258
16359test-smoke :
16460 $(MAKE ) -C tests/ test-smoke
165-
166- uninstall : check-fleet stop
167- $(FLEETCTL ) unload -block-attempts=600 $(call deis_units,.)
168- $(FLEETCTL ) destroy $(strip $(call deis_units,.) )
0 commit comments