-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
107 lines (86 loc) · 2.88 KB
/
Makefile
File metadata and controls
107 lines (86 loc) · 2.88 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
.PHONY: help build run dev release clean stop kill-port test demo client install check fmt clippy perf stress latency
# Variables
PORT := 5000
BINARY := pubsub_server
DB_FILE := pubsub.db
TESTS_DIR := tests
help:
@echo "Available commands:"
@echo " make build - Build the project in debug mode"
@echo " make release - Build the project in release mode"
@echo " make run - Stop any running server and run in debug mode"
@echo " make dev - Stop any running server and run in release mode"
@echo " make stop - Stop the running server"
@echo " make kill-port - Kill any process using port $(PORT)"
@echo " make clean - Clean build artifacts and database"
@echo " make clean-db - Remove only the database file"
@echo " make test - Run tests"
@echo " make demo - Run the Python Socket.IO demo client"
@echo " make client - Install Python dependencies and run demo client"
@echo " make install - Install Python dependencies"
@echo " make perf - Run performance test"
@echo " make stress - Run stress test"
@echo " make latency - Run latency analysis"
@echo " make check - Run cargo check"
@echo " make fmt - Format the code"
@echo " make clippy - Run clippy linter"
build:
@echo "Building in debug mode..."
cargo build
release:
@echo "Building in release mode..."
cargo build --release
run: stop
@echo "Starting server in debug mode..."
@cargo run
dev: stop
@echo "Starting server in release mode..."
@./target/release/$(BINARY) 2>&1 || ($(MAKE) release && ./target/release/$(BINARY))
stop:
@echo "Stopping any running servers..."
@pkill -9 $(BINARY) 2>/dev/null || true
@sleep 1
kill-port:
@echo "Killing process on port $(PORT)..."
@lsof -ti:$(PORT) | xargs kill -9 2>/dev/null || true
@sleep 1
clean: stop
@echo "Cleaning build artifacts and database..."
cargo clean
rm -f $(DB_FILE) $(DB_FILE)-shm $(DB_FILE)-wal
clean-db:
@echo "Removing database files..."
rm -f $(DB_FILE) $(DB_FILE)-shm $(DB_FILE)-wal
test:
@echo "Running tests..."
cargo test
demo: client
client:
@echo "Running Python Socket.IO demo client..."
@python3 $(TESTS_DIR)/demo_socketio.py
install:
@echo "Installing Python dependencies..."
pip3 install --break-system-packages python-socketio requests
perf:
@echo "Running performance test..."
@python3 $(TESTS_DIR)/perf_test.py
stress:
@echo "Running stress test..."
@python3 $(TESTS_DIR)/stress_test.py
latency:
@echo "Running latency analysis..."
@python3 $(TESTS_DIR)/latency_analysis.py
check:
@echo "Running cargo check..."
cargo check
fmt:
@echo "Formatting code..."
cargo fmt
clippy:
@echo "Running clippy..."
cargo clippy -- -D warnings
# Fresh start - kill everything, clean DB, and rebuild
fresh: stop kill-port clean-db
@echo "Fresh start: cleaning and rebuilding..."
@$(MAKE) release
@echo "Ready to run with: make dev"