-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (61 loc) · 2.42 KB
/
Makefile
File metadata and controls
73 lines (61 loc) · 2.42 KB
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
# ─── OS Detection ────────────────────────────────────────────────────────────
ifeq ($(OS),Windows_NT)
MVN := mvnw.cmd
KILL_JAVA := taskkill /F /IM java.exe
else
MVN := ./mvnw
KILL_JAVA := pkill -f "java -jar" || true
endif
JAVA := java
JAR_GW := api-gateway/target/api-gateway.jar
JAR_ORD := order-service/target/order-service.jar
JAR_PAY := payment-service/target/payment-service.jar
JAR_NOT := notification-service/target/notification-service.jar
.PHONY: all build start stop docker-up docker-down test clean help
# ─── Targets ─────────────────────────────────────────────────────────────────
all: docker-up build start
build:
ifeq ($(OS),Windows_NT)
$(MVN) clean package -DskipTests
else
chmod +x mvnw
$(MVN) clean package -DskipTests
endif
docker-up:
docker-compose up -d
docker-down:
docker-compose down
# Windows: opens each service in a new terminal window.
# Linux/Mac: runs each service in the background, logging to *.log files.
start:
ifeq ($(OS),Windows_NT)
cmd /C start "API Gateway" $(JAVA) -jar $(JAR_GW)
cmd /C start "Order Service" $(JAVA) -jar $(JAR_ORD)
cmd /C start "Payment Service" $(JAVA) -jar $(JAR_PAY)
cmd /C start "Notification Service" $(JAVA) -jar $(JAR_NOT)
else
$(JAVA) -jar $(JAR_GW) > api-gateway.log 2>&1 &
$(JAVA) -jar $(JAR_ORD) > order-service.log 2>&1 &
$(JAVA) -jar $(JAR_PAY) > payment-service.log 2>&1 &
$(JAVA) -jar $(JAR_NOT) > notification-service.log 2>&1 &
@echo "Services started. Follow logs with: tail -f api-gateway.log"
endif
stop:
-$(KILL_JAVA)
test:
curl -s -X POST http://localhost:8080/api/order \
-H "Content-Type: application/json" \
-d '{"id":1,"product":"Widget","quantity":2,"price":19.99}'
clean:
$(MVN) clean
help:
@echo ""
@echo " make all - docker-up + build + start"
@echo " make build - compile and package all JARs"
@echo " make docker-up - start RabbitMQ"
@echo " make docker-down - stop RabbitMQ"
@echo " make start - launch all four services"
@echo " make stop - kill all Java processes"
@echo " make test - POST a test order to the API"
@echo " make clean - remove build artifacts"
@echo ""