forked from fluidex/dingir-exchange
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (56 loc) · 1.99 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
DB="postgres://exchange:[email protected]/exchange"
DB_RESET_DIR="migrations/reset"
BUILD_MODE="debug"
# tokio-runtime-worker does not work well, do not know why...
PROCESSES="restapi|persistor|matchengine|tokio-runtime-w|ticker.ts"
CURRENTDATE=`date +"%Y-%m-%d"`
# code related
lint:
cargo fmt --all -- --check
cargo clippy -- -D warnings
fmtsql:
find migrations -type f | xargs -L 1 pg_format --type-case 2 -i
fmtrs:
cargo fmt --all
fmtjs:
cd examples/js && yarn fmt
fmt: fmtsql fmtrs fmtjs
# docker related
start-compose:
# cd orchestra/docker; docker compose up -d exchange_db exchange_zookeeper exchange_kafka exchange_envoy
cd orchestra/docker; docker-compose up -d exchange_db exchange_zookeeper exchange_kafka exchange_envoy
stop-compose:
# cd orchestra/docker; docker compose down exchange_db exchange_zookeeper exchange_kafka exchange_envoy
cd orchestra/docker; docker-compose down
clean-compose: stop-compose
rm -rf orchestra/docker/volumes/exchange_*
# process relared
startall:
cargo build
mkdir -p logs
`pwd`/target/$(BUILD_MODE)/persistor 1>logs/persistor.$(CURRENTDATE).log 2>&1 &
`pwd`/target/$(BUILD_MODE)/matchengine 1>logs/matchengine.$(CURRENTDATE).log 2>&1 &
sleep 3;
`pwd`/target/$(BUILD_MODE)/restapi 1>logs/restapi.$(CURRENTDATE).log 2>&1 &
list:
pgrep -l $(PROCESSES) || true
stopall:
pkill -INT $(PROCESSES) || true
(pgrep -l $(PROCESSES) && (echo '"pkill -INT" failed, force kill'; pkill $(PROCESSES))) || true
# logs related
taillogs:
tail -n 15 logs/*
viewlogs:
watch -n 0.5 tail -n 4 logs/*
rmlogs:
rm -rf logs/*
# db related
conn:
psql $(DB)
cleardb:
# https://stackoverflow.com/a/13823560/2078461
psql $(DB) -X -a -f $(DB_RESET_DIR)/down.sql
psql $(DB) -X -a -f $(DB_RESET_DIR)/up.sql
dump-trades:
psql $(DB) -c "select count(*) from user_trade where market = 'ETH_USDT' and user_id = 6"
psql $(DB) -t -A -F"," -c "select time, side, role, price, amount, quote_amount from user_trade where market = 'ETH_USDT' and user_id = 6 order by time asc" > trades.csv