-
Notifications
You must be signed in to change notification settings - Fork 0
/
startGeneral.sh
98 lines (84 loc) · 3.17 KB
/
startGeneral.sh
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
#!/bin/bash
REDIS_INVOKE='redis-server redis.conf'
REDIS_START_DIR='$HOME/config/ga-bitbot/config'
GAL_INVOKE='pypy gal.py'
GAL_START_DIR='$HOME/config/ga-bitbot'
NODE_INVOKE='node server.js'
NODE_START_DIR='$HOME/config/ga-bitbot/tools/nimbs'
BOOKIE_INVOKE='python bcbookie.py'
BOOKIE_START_DIR='$HOME/config/ga-bitbot'
BIDMAKER_INVOKE='python bid_maker.py'
BIDMAKER_START_DIR='$HOME/config/ga-bitbot'
USERNAME='trader'
ME=`whoami`
as_user() {
if [ $ME == $USERNAME ] ; then
bash -c "$1"
else
su - $USERNAME -c "$1"
fi
}
all_start() {
if [ `ps auxwww | grep bcbookie.py | grep -v grep | wc -l` -eq 0 ] ; then
# get bcbookie password
echo "Please enter your bcbookie.py password to continue : "
read BCBPW
fi
# set up screens
if [ `screen -list | grep redissrv | wc -l` -eq 0 ] ; then screen -dmS redissrv ; fi
if [ `screen -list | grep gal | wc -l` -eq 0 ] ; then screen -dmS gal ; fi
if [ `screen -list | grep node | wc -l` -eq 0 ] ; then screen -dmS node ; fi
if [ `screen -list | grep bookie | wc -l` -eq 0 ] ; then screen -dmS bookie ; fi
if [ `screen -list | grep bidmaker | wc -l` -eq 0 ] ; then screen -dmS bidmaker ; fi
echo "Screens loaded..."
echo `screen -list`
# if redis-server not running, start it.
if [ `ps auxwww | grep redis-server | grep -v grep | wc -l` -eq 0 ] ; then
as_user "screen -p 0 -S redissrv -X eval 'stuff \"cd $REDIS_START_DIR\"\015' "
as_user "screen -p 0 -S redissrv -X eval 'stuff \"$REDIS_INVOKE\"\015' "
echo "-- redis-server started."
sleep 2
else
echo "** redis-server already running!!"
fi
# change dir and start gal.py if needed
if [ `ps auxwww | grep gal.py | grep -v grep | wc -l` -eq 0 ] ; then
as_user "screen -p 0 -S gal -X eval 'stuff \"cd $GAL_START_DIR\"\015' "
as_user "screen -p 0 -S gal -X eval 'stuff \"$GAL_INVOKE\"\015' "
echo "-- gal.py started."
sleep 60
else
echo "** gal.py already running!!"
fi
# start node server.js if needed
if [ `ps auxwww | grep server.js | grep -v grep | wc -l` -eq 0 ] ; then
as_user "screen -p 0 -S node -X eval 'stuff \"cd $NODE_START_DIR\"\015' "
as_user "screen -p 0 -S node -X eval 'stuff \"$NODE_INVOKE\"\015' "
echo "-- node server.js started."
sleep 5
else
echo "** node server.js already running!!"
fi
# start bcbookie if needed
if [ `ps auxwww | grep bcbookie.py | grep -v grep | wc -l` -eq 0 ] ; then
as_user "screen -p 0 -S bookie -X eval 'stuff \"cd $BOOKIE_START_DIR\"\015' "
as_user "screen -p 0 -S bookie -X eval 'stuff \"$BOOKIE_INVOKE\"\015' "
sleep 5
as_user "screen -p 0 -S bookie -X eval 'stuff \"$BCBPW\"\015'"
echo "-- bcbookie.py started."
sleep 5
else
echo "** bcbookie.py already running!!"
fi
# start bid_maker if needed
if [ `ps auxwww | grep bid_maker.py | grep -v grep | wc -l` -eq 0 ] ; then
as_user "screen -p 0 -S bidmaker -X eval 'stuff \"cd $BIDMAKER_START_DIR\"\015' "
as_user "screen -p 0 -S bidmaker -X eval 'stuff \"$BIDMAKER_INVOKE\"\015' "
echo "-- bid_maker.py started."
sleep 5
else
echo "** bid_maker.py already running!!"
fi
}
all_start
# for i in `ps auxw|grep -i screen|grep -v grep | awk '{print $13}'` ; do screen -p 0 -S $i -X eval 'stuff ^C' ; screen -p 0 -S $i -X eval 'stuff \"exit\"\015' ; done