-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile_advance
81 lines (76 loc) · 4.53 KB
/
Makefile_advance
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
################################################################################################
# This Makefile is intended to make executing, building and testing of edgex services convinient
# This Makefile aims to acheive this using without docker
# Makefile advanced is similar to Makefile but includes some cool aesthetics
# Makefile advanced most of the functionalities will be improved from the UI perspective.
################################################################################################
# Function to show loading animation
define show_loading
while :; do \
for s in ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏; do \
printf "\r\033[33m$$s Container edgex-core-consul ::: started\033[0m"; \
sleep 0.05; \
done; \
done
endef
# Function to check service status
define check_service
START_TIME=$$(date +%s); \
END_TIME=$$((START_TIME + 18)); \
while :; do \
CURRENT_TIME=$$(date +%s); \
if [ $$CURRENT_TIME -ge $$END_TIME ]; then \
printf "\r\033[31m⠹ Container edgex-core-consul ::: failed!\033[0m\n"; \
kill $${LOADING_PID}; \
break; \
elif curl -s -o /dev/null -w "%{http_code}" http://127.0.0.2:8500/v1/status/leader | grep -q "200"; then \
if [ $$CURRENT_TIME -ge $$((START_TIME + 5)) ]; then \
printf "\r\033[32m✔ Container edgex-core-consul ::: Running\033[0m\n"; \
kill $${LOADING_PID}; \
break; \
fi; \
fi; \
sleep 1; \
done
endef
###################################################################################################
# The below seciton of Makefile enables user to start and end edgex services using a single command
###################################################################################################
# Makefile command that will allow to start all services at once.
# Currently only consul is up and running as a service, need to implement for other service as well
start-all-services:
@nohup consul agent -ui -bootstrap -server -client 127.0.0.1 -bind 127.0.0.1 -advertise 127.0.0.1 -data-dir=tmp/consul > ~/edgex-foundry/edgex-native-build-3.1-napa/edgex-service-logs/edgex-consul-agent/nohup.out 2>&1 &
@$(call show_loading) & \
LOADING_PID=$$!; \
$(call check_service)
# Makefile command that will allow to stop all services at once.
# Is able to stop all the services but, after the loading animation, sucess log is defined beside loading animation which needs fixing.
stop-all-services:
@ps aux | grep 'consul agent' | grep -v grep | awk '{print $$2}' | xargs -r kill -15
@ps aux | grep 'core-metadata' | grep -v grep | awk '{print $$2}' | xargs -r kill -15 > /dev/null 2>&1 &
@ps aux | grep 'core-data' | grep -v grep | awk '{print $$2}' | xargs -r kill -15 > /dev/null 2>&1 &
@ps aux | grep 'core-command' | grep -v grep | awk '{print $$2}' | xargs -r kill -15 > /dev/null 2>&1 &
@ps aux | grep 'support-notifications' | grep -v grep | awk '{print $$2}' | xargs -r kill -15 > /dev/null 2>&1 &
@ps aux | grep 'support-scheduler' | grep -v grep | awk '{print $$2}' | xargs -r kill -15 > /dev/null 2>&1 &
@ps aux | grep 'app-service-configurable' | grep -v grep | awk '{print $$2}' | xargs -r kill -15 > /dev/null 2>&1 &
@ps aux | grep 'device-virtual' | grep -v grep | awk '{print $$2}' | xargs -r kill -15 > /dev/null 2>&1 &
@ps aux | grep 'edgex-ui-server' | grep -v grep | awk '{print $$2}' | xargs -r kill -15 > /dev/null 2>&1 &
@ps aux | grep 'kuiperd' | grep -v grep | awk '{print $$2}' | xargs -r kill -15 > /dev/null 2>&1 &
@while ps aux | grep -E 'consul agent|core-metadata|core-data|core-command|support-notifications|support-scheduler|app-service-configurable|device-virtual|edgex-ui-server|kuiperd' | grep -v grep > /dev/null; do \
for c in ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏; do \
printf "\r\033[33m$$c Edgex service is killing all services, please wait.. ::: started\033[0m"; \
sleep 0.05; \
done; \
done
@if ps aux | grep -E 'consul agent|core-metadata|core-data|core-command|support-notifications|support-scheduler|app-service-configurable|device-virtual|edgex-ui-server|kuiperd' | grep -v grep > /dev/null; then \
echo "\033[33m::: EdgeX services are still running :::\033[0m"; \
else \
echo "\033[32m✔ ::: All EdgeX services have stopped working :::\033[0m"; \
fi
#####################################################
# The below showcases services status, like PID etc..
# ALl service status is shown with htop filtered view
#####################################################
edgex-services-htop-status:
@echo "::: Filtering EdgeX services and displaying with htop :::"
@./htop-filter.sh