-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
94 lines (80 loc) · 2.07 KB
/
Makefile
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
82
83
84
85
86
87
88
89
90
91
92
93
94
# base conf
PWD=$(realpath ./)
BUILD=$(PWD)/build
$(shell mkdir -p $(BUILD))
SCRIPTS=$(PWD)/scripts
# OpenResty ROOT
OR=openresty
TMP=$(BUILD)/tmp
OR_ROOT := $(shell \
${OR} -V &> $(TMP) && cat $(TMP) \
| grep prefix |sed 's/.*prefix\=\(.*\)\/nginx.*/\1/g' \
)
SITE_LUALIB_ROOT=$(OR_ROOT)/site/lualib
$(shell rm $(TMP))
# create app
APP_NAME ?= motan-demo
APP_ROOT ?= $(PWD)/app
PID=$(APP_ROOT)/$(APP_NAME)/logs/nginx.pid
.PHONY: all
all: install create rundev
@echo "all-ok"
.PHONY: install
install: dependence build
@echo "install motan success."
.PHONY: dependence
dependence:
@echo "get motan dependences libs."
@chmod +x $(SCRIPTS)/dorequire
@$(SCRIPTS)/dorequire
@echo "motan dependences libs get done."
.PHONY: create
create:
@chmod +x $(SCRIPTS)/createapp
@APP_NAME=$(APP_NAME) APP_ROOT=$(APP_ROOT) $(SCRIPTS)/createapp
@echo "create app: "$(APP_NAME)" success."
.PHONY: build
build:
@cp -fR $(PWD)/lib/motan $(SITE_LUALIB_ROOT)
@mkdir -p $(SITE_LUALIB_ROOT)/resty/
@cp $(BUILD)/require/resty/* $(SITE_LUALIB_ROOT)/resty/
@echo "build motan success."
@rm -rf $(BUILD)
@echo "build clean success."
.PHONY: clean
clean:
@rm -rf $(BUILD) $(APP_ROOT)
@echo "clean success."
.PHONY: run
run:
@mkdir -p $(APP_ROOT)/$(APP_NAME)/logs
ifeq ($(PID), $(wildcard $(PID)))
@$(OR) -p $(APP_ROOT)/$(APP_NAME) -s stop
@echo "stop success."
@$(OR) -p $(APP_ROOT)/$(APP_NAME)
@echo "restart success."
else
@$(OR) -p $(APP_ROOT)/$(APP_NAME)
@echo "start success."
endif
.PHONY: stop
stop:
@$(OR) -p $(APP_ROOT)/$(APP_NAME) -s stop
@echo "stop success."
.PHONY: rundev
rundev:
@cp -fR $(PWD)/lib/motan $(SITE_LUALIB_ROOT)
@mkdir -p $(APP_ROOT)/$(APP_NAME)/logs
ifeq ($(PID), $(wildcard $(PID)))
@MOTAN_ENV=development $(OR) -p $(APP_ROOT)/$(APP_NAME) -s stop
@echo "dev stop success."
@MOTAN_ENV=development $(OR) -p $(APP_ROOT)/$(APP_NAME)
@echo "dev restart success."
else
@MOTAN_ENV=development $(OR) -p $(APP_ROOT)/$(APP_NAME)
@echo "dev start success."
endif
.PHONY: stopdev
stopdev:
@MOTAN_ENV=development $(OR) -p $(APP_ROOT)/$(APP_NAME) -s stop
@echo "stopdev success."