forked from hummingbot/hummingbot
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhb_altmarkets_docker.template.bash
70 lines (58 loc) · 2.35 KB
/
hb_altmarkets_docker.template.bash
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
# hb_altmarkets_docker.bash
#
# OPTIONS:
# hb_altmarkets_docker.sh BUILD # don't need to specify instance number here.
# hb_altmarkets_docker.sh START X # Where X is the hummingbot instance - can be any number but might as well start from 1 right?
# # Can run as many instances as you like by repeating the command with new number
# hb_altmarkets_docker.sh DEL X # Where X is the MAX hummingbot instance - it will go through all instances up to this number and delete logs/data but NOT conf files
# Change this to the path where you clones hummingbot to
HUMMINGBOT_DIRECTORY=/somedir/hummingbot
NUM=1
if [ ! -z $2 ]
then
NUM=$2
fi
BUILD_NAME=hummingbot1
INSTANCE_NAME=hummingbot-instance$NUM
DIR_NAME=hummingbot_files$NUM
cd $HUMMINGBOT_DIRECTORY
if [ ! -z $1 ] && [ $1 == 'BUILD' ] ; then
docker image rm --force $BUILD_NAME
docker build -t $BUILD_NAME .
exit 0
fi
cd ./installation/docker-commands/hummingbot_files/
if [ ! -z $1 ] && [ $1 == 'DEL' ] && [ ! -z $2 ]; then
echo "Deleting all logs/data for bots."
for i in $(seq 1 $2); do
echo "Deleting bot $i"
rm -r hummingbot_files$i/hummingbot_logs/* && \
rm -r hummingbot_files$i/hummingbot_data/*
docker container rm hummingbot-instance$i
done
exit 0
fi
if [ ! -z $1 ] && [ $1 == 'START' ] && [ ! -z $2 ]; then
mkdir -p $DIR_NAME/hummingbot_conf && \
mkdir $DIR_NAME/hummingbot_logs && \
mkdir $DIR_NAME/hummingbot_data && \
mkdir $DIR_NAME/hummingbot_scripts
docker run -it \
--network host \
--name $INSTANCE_NAME \
--mount "type=bind,source=$(pwd)/$DIR_NAME/hummingbot_conf,destination=/conf/" \
--mount "type=bind,source=$(pwd)/$DIR_NAME/hummingbot_logs,destination=/logs/" \
--mount "type=bind,source=$(pwd)/$DIR_NAME/hummingbot_data,destination=/data/" \
--mount "type=bind,source=$(pwd)/$DIR_NAME/hummingbot_scripts,destination=/scripts/" \
$BUILD_NAME || \
# docker start -i -a $INSTANCE_NAME
docker container rm $INSTANCE_NAME && \
docker run -it \
--network host \
--name $INSTANCE_NAME \
--mount "type=bind,source=$(pwd)/$DIR_NAME/hummingbot_conf,destination=/conf/" \
--mount "type=bind,source=$(pwd)/$DIR_NAME/hummingbot_logs,destination=/logs/" \
--mount "type=bind,source=$(pwd)/$DIR_NAME/hummingbot_data,destination=/data/" \
--mount "type=bind,source=$(pwd)/$DIR_NAME/hummingbot_scripts,destination=/scripts/" \
$BUILD_NAME
fi