-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (71 loc) · 2.29 KB
/
Makefile
File metadata and controls
86 lines (71 loc) · 2.29 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
# Makefile for Purro Token Price API
# Variables
GO=go
PORT=8080
PRICE_UPDATE_INTERVAL=1h
# Build targets
.PHONY: build clean run run-api run-updater run-server test init-db migrate-db import-tokens serve-docs
# Build all binaries
build: build-api build-updater
# Build API server
build-api:
$(GO) build -o bin/api_server api_server.go
# Build price updater
build-updater:
$(GO) build -o bin/price_updater price_updater.go
# Clean build artifacts
clean:
rm -rf bin/
mkdir -p bin/
# Run API server
run-api:
$(GO) run api_server.go
# Run price updater
run-updater:
$(GO) run price_updater.go $(PRICE_UPDATE_INTERVAL)
# Run both API server and price updater
run-server:
@echo "Starting price updater and API server..."
@mkdir -p logs/
$(GO) run price_updater.go $(PRICE_UPDATE_INTERVAL) > logs/price_updater.log 2>&1 &
@echo "Price updater started with interval: $(PRICE_UPDATE_INTERVAL)"
$(GO) run api_server.go
# Run tests
test:
$(GO) test ./...
# Initialize database
init-db:
@echo "Initializing database..."
createdb -U postgres purro_token_prices || true
psql -U postgres -d purro_token_prices -f scripts/init_database.sql
# Apply database migrations
migrate-db:
@echo "Applying database migrations..."
psql -U postgres -d purro_token_prices -f scripts/add_keep_for_history_column.sql
# Import tokens from Hyperliquid
import-tokens:
@echo "Importing tokens from Hyperliquid..."
$(GO) run scripts/import_hyperliquid.go import-tokens
# Serve Swagger documentation
serve-docs:
@echo "Starting Swagger UI server on http://localhost:8082"
@cd docs/swagger && go run server.go
# Help
help:
@echo "Purro Token Price API Makefile"
@echo ""
@echo "Usage:"
@echo " make build - Build all binaries"
@echo " make clean - Clean build artifacts"
@echo " make run-api - Run API server"
@echo " make run-updater - Run price updater"
@echo " make run-server - Run both API server and price updater"
@echo " make test - Run tests"
@echo " make init-db - Initialize database"
@echo " make migrate-db - Apply database migrations"
@echo " make import-tokens - Import tokens from Hyperliquid"
@echo " make serve-docs - Serve Swagger API documentation"
@echo ""
@echo "Variables:"
@echo " PORT=$(PORT)"
@echo " PRICE_UPDATE_INTERVAL=$(PRICE_UPDATE_INTERVAL)"