Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis and sentinel configs #61

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
76f379b
gitignore: update ignore to exclude binaries
andrewshvv Oct 5, 2017
0a23589
makefile: change on linux installation
andrewshvv Oct 5, 2017
04d5983
test: update scripts
andrewshvv Oct 5, 2017
e7a022c
matchengine: make return code consistent
andrewshvv Oct 5, 2017
6e44b11
matchengine: add new cryptocurrencies
andrewshvv Oct 28, 2017
983e52a
matchengine: switch stock and money in config
andrewshvv Nov 1, 2017
c6bfedb
matchengine: change currency precious
andrewshvv Nov 2, 2017
c96608a
matchengine: change availabel pairs
andrewshvv Feb 26, 2018
2be8e93
docker: add mysql docker
dsame Feb 19, 2018
ffb8b82
docker: add kafka to docker-compose
dsame Feb 19, 2018
ec061a4
docker: rm update && upgrade from mysql Dockerfile for sake of stability
dsame Feb 19, 2018
8469ffb
docker: add kafka
dsame Feb 19, 2018
10b2f3f
docker: add redis
dsame Feb 19, 2018
64b251c
docker: redis run from reference docker-compose.yml
dsame Feb 20, 2018
6405328
docker: add sentinel docker
dsame Feb 20, 2018
9449b97
docker: add sentinel docker
dsame Feb 20, 2018
b0a52b1
docker: rm entrypoint from redis
dsame Feb 20, 2018
10c7e9e
docker: docker-compose for exchange draft
dsame Feb 20, 2018
c7e6c29
docker: add mysql docker diagnostic
dsame Feb 20, 2018
e9c7ca2
docker: ensure sentinel cluster is up; ensure all services are up; ad…
dsame Feb 21, 2018
cf1589d
docker: add cli dockerfile
dsame Feb 23, 2018
703d5f1
docker: mount /var/zookeeper to host filesystem
dsame Feb 23, 2018
7563869
docker: add logging option to limit console log size to 10mb
dsame Feb 23, 2018
a34a16d
utils: general: add `/bin` directory with set of shell scripts mirror…
dsame Feb 21, 2018
10094cd
utils: general: add `/bin` directory with set of shell scripts mirror…
dsame Feb 21, 2018
54c43a4
docker: configuration: kafka: change log rotation params
dsame Feb 26, 2018
66d3506
dockerize: rm COPY entrypoint.sh from redis
dsame Feb 26, 2018
a0aa625
dockerize: rm COPY entrypoint.sh from redis
dsame Feb 26, 2018
6bde213
dockerize: rm COPY entrypoint.sh from sentinel
dsame Feb 26, 2018
80d1f7c
dockerize: add docker/exchange/entrypoint.sh - it was lost somehow
dsame Feb 26, 2018
639cb19
dockerize: chmod +x docker/exchange/entrypoint.sh
dsame Feb 26, 2018
fc547a8
docker: connect sentinel2 to redis-replica-2 & add dependicies of exc…
dsame Feb 27, 2018
6accd51
docker: add entrypoint to redis
dsame Feb 27, 2018
d4cee4d
docker: add entrypoint to sentinel
dsame Feb 27, 2018
f50c901
docker: add libmysqlclient20 to exchange run time dependencies and fi…
dsame Feb 27, 2018
804605a
docker: fix makefiles in order to compile services with ubuntu binaries
dsame Feb 27, 2018
a77f08f
utilities: add scripts asset.list, market.list, init
dsame Feb 27, 2018
5b535f0
utilities: add asset.list function
dsame Feb 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
test/matchengine/cli
accesshttp/accesshttp
accessws/accessws
alertcenter/alertcenter
marketprice/marketprice
readhistroy/readhistory

# Compiled Object files
*.slo
*.lo
Expand Down Expand Up @@ -260,7 +267,6 @@ $RECYCLE.BIN/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

Expand Down
2 changes: 1 addition & 1 deletion accesshttp/makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TARGET := accesshttp.exe
TARGET := accesshttp
INCS = -I ../network -I ../utils
LIBS = -L ../utils -lutils -L ../network -lnetwork -Wl,-Bstatic -lev -ljansson -lmpdec -lrdkafka -lz -lssl -lcrypto -lhiredis -Wl,-Bdynamic -lm -lpthread -ldl
include ../makefile.inc
4 changes: 2 additions & 2 deletions accesshttp/restart.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

killall -s SIGQUIT accesshttp.exe
killall -s SIGQUIT accesshttp
sleep 1
./accesshttp.exe config.json
./accesshttp config.json
4 changes: 2 additions & 2 deletions accessws/makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TARGET := accessws.exe
TARGET := accessws
INCS = -I ../network -I ../utils
LIBS = -L ../utils -lutils -L ../network -lnetwork -Wl,-Bstatic -lev -ljansson -lmpdec -lrdkafka -lz -lssl -lcrypto -lhiredis -lcurl -Wl,-Bdynamic -lm -lpthread -ldl
LIBS = -L ../utils -lutils -L ../network -lnetwork -Wl,-Bstatic -lev -ljansson -lmpdec -lrdkafka -lz -lssl -lcrypto -lhiredis -Wl,-Bdynamic -lm -lpthread -ldl -lcurl
include ../makefile.inc
4 changes: 2 additions & 2 deletions accessws/restart.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

killall -s SIGQUIT accessws.exe
killall -s SIGQUIT accessws
sleep 1
./accessws.exe config.json
./accessws config.json
4 changes: 2 additions & 2 deletions alertcenter/makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TARGET := alertcenter.exe
TARGET := alertcenter
INCS = -I ../network -I ../utils
LIBS = -L ../utils -lutils -L ../network -lnetwork -Wl,-Bstatic -lev -lhiredis -ljansson -lmpdec -lcurl -lssl -lcrypto -Wl,-Bdynamic -lm
LIBS = -L ../utils -lutils -L ../network -lnetwork -Wl,-Bstatic -lev -lhiredis -ljansson -lmpdec -lssl -lcrypto -Wl,-Bdynamic -lm -lcurl
include ../makefile.inc
4 changes: 2 additions & 2 deletions alertcenter/restart.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

killall -s SIGQUIT alertcenter.exe
killall -s SIGQUIT alertcenter
sleep 1
./alertcenter.exe config.json
./alertcenter config.json
98 changes: 98 additions & 0 deletions bin/accesshttp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash

echo @=$@

if [ x$1 = x--help -o x$1 = x-h ];then
echo "With params calls http access service"
echo " $0 METHOD [comma separated params]"
echo "Without params adds the highlevel functions to the environment"
echo " $0"
echo "Exported functions are:"
echo " rpc METHOD [comma separated params]"
echo " balance_update user_id asset deposit | withdraw op_id amount"
echo " order_put_market user_id 1(sell)|2(buy) amount taker_fee_rate [source]"
exit 0
fi

shdir=`dirname ${0}`

if [ -z $HTTP_URL ];then
. ${shdir}/config.sh
HTTP_URL="http://$( accesshttp_bind )"
fi

function rpc () {
method=$1
shift
if [ ! -z $DEBUG ];then
echo "{\"method\":\"${method}\",\"params\":[$1],\"id\":${RANDOM}}"
fi
curl -i -H 'Accept: application/json' \
-X POST \
-d "{\"method\":\"${method}\",\"params\":[$1],\"id\":${RANDOM}}" \
$HTTP_URL
RESULT=$?
echo
return $RESULT
}

function balance.query () {
if [ $# -lt 1 ]; then
echo "bad arguments: $@"
echo 'usage: user_id'
return 1
fi
rpc balance.query $1
}

# user_id
# asset
# deposit | withdraw
# op_id
# amount
function balance.update () {
rpc balance.update "$1,\"$2\",\"$3\",$4,\"$5\",{}"
}

function order.put_market () {
if [ $# -lt 5 ]; then
echo "bad arguments: $@"
echo 'usage: user_id market 1(sell)|2(buy) amount taker_fee_rate [source]'
return 1
fi
source=$6
test $source || source="shell command"
rpc order.put_market "$1,\"$2\",$3,\"$4\",\"$5\",\"$source\""
}

function order.put_market () {
if [ $# -lt 5 ]; then
echo "bad arguments: $@"
echo 'usage: user_id market 1(sell)|2(buy) amount taker_fee_rate [source]'
return 1
fi
source=$6
test $source || source="shell command"
rpc order.put_market "$1,\"$2\",$3,\"$4\",\"$5\",\"$source\""
}

function market.status () {
if [ $# -lt 2 ]; then
echo "bad arguments: $@"
echo 'usage: market period'
return 1
fi
rpc "market.status" "\"$1\",$2"
}

function market.list () {
rpc "market.list"
}

function asset.list () {
rpc "asset.list"
}

# if [ $# -gt 0 ];then
# rpc $@
# fi
6 changes: 6 additions & 0 deletions bin/asset.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

shdir=`dirname ${0}`
. ${shdir}/accesshttp

asset.list
5 changes: 5 additions & 0 deletions bin/balance.query
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
shdir=`dirname ${0}`
. ${shdir}/accesshttp

balance.query $@
10 changes: 10 additions & 0 deletions bin/balance.update
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
if [ $# -eq 0 -o x$1 = x--help -o x$1 = x-h ];then
echo "$0 user_id asset deposit | withdraw op_id amount"
exit 0
fi

shdir=`dirname ${0}`
. ${shdir}/accesshttp

balance.update $@
42 changes: 42 additions & 0 deletions bin/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# Exports functions parsing the services configs

# Internal utils
servicesdir="`dirname ${0}`/.."

function get () {
filter=$1
service=$2
config="${servicesdir}/$service/config.json"
ret=`jq "$filter[0]" < $config`
test -z $ret || test $ret = null && $ret=''
if [ -z $ret ]; then
ret=`jq $filter[0] < $config`
test -z ret && return 1
fi
echo $ret
}

function trim_quotes () {
echo $1|sed -e's/^"//'|sed -e's/"$//'
}

function trim_port() {
echo $1|sed -e's/^[^@]*@//'
}

function trim_quotes_port() {
echo $1|sed -e's/^"//'|sed -e's/"$//'|sed -e's/^[^@]*@//'
}

# Exported functions
function accesshttp_bind () {
if [ -z $REMOTE ]; then
# get .svr.bind accesshttp
ip=$( get .svr.bind accesshttp )
# echo "ip=$ip"
trim_quotes_port $ip
else
echo $REMOTE
fi
}
27 changes: 27 additions & 0 deletions bin/init
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

shdir=`dirname ${0}`
. ${shdir}/accesshttp

OP=3

balance.update 1 BTC deposit $OP 1000
balance.update 1 ETH deposit $OP 1000
balance.update 1 BCH deposit $OP 1000
balance.update 1 LTC deposit $OP 1000
balance.update 1 DASH deposit $OP 1000

balance.update 2 BTC deposit $OP 1000
balance.update 2 ETH deposit $OP 1000
balance.update 2 BCH deposit $OP 1000
balance.update 2 LTC deposit $OP 1000
balance.update 2 DASH deposit $OP 1000

balance.update 1121516550 BTC deposit $OP 1000
balance.update 1121516550 ETH deposit $OP 1000
balance.update 1121516550 BCH deposit $OP 1000
balance.update 1121516550 LTC deposit $OP 1000
balance.update 1121516550 DASH deposit $OP 1000

order.put_market 1121516550 BTCETH 1 0.00001 0.0000001
order.put_market 1121516550 BTCBCH 1 0.00001 0.0000001
6 changes: 6 additions & 0 deletions bin/market.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

shdir=`dirname ${0}`
. ${shdir}/accesshttp

market.list
6 changes: 6 additions & 0 deletions bin/market.status
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

shdir=`dirname ${0}`
. ${shdir}/accesshttp

market.status $@
6 changes: 6 additions & 0 deletions bin/order.put_market
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

shdir=`dirname ${0}`
. ${shdir}/accesshttp

order.put_market $@
16 changes: 16 additions & 0 deletions docker/cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ubuntu:16.04
MAINTAINER Sergey Dolin <[email protected]>

RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
mysql-client \
inetutils-ping \
net-tools \
lsof \
telnet && \
rm -rf /var/lib/apt/lists/*

RUN echo 'while true;do sleep 3600;done' > /wait
RUN chmod +x /wait
CMD /wait
Loading