-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdog_trainerctl
executable file
·98 lines (83 loc) · 2.31 KB
/
dog_trainerctl
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
98
#!/bin/bash
export ERL_MAX_ETS_TABLES=8192
APPNAME="dog_trainer"
HOST=`/bin/hostname -s`
ERL=`which erl`
DOG_HOME=/opt/dog_trainer
AWK=`which awk`
SED=`which sed`
PF=`which printf`
ERL_VER=`$ERL +V 2>&1 | $AWK '{print $6}' | $SED "s/$($PF '\r')//"`
ERL_LIBS=${ERL_LIBS}:${DOG_HOME}:${DOG_HOME}/deps
export ERL_LIBS=${ERL_LIBS}
ENV_VARS="ERL_MAX_ETS_TABLES 4096"
export ERL_FULLSWEEP_AFTER=0
mkdir /tmp/dog_trainer/
start() {
echo "Starting dog_trainer"
NODE="dog_trainer@${HOST}"
$ERL 128 +P 4194304 +A 128 \
-noinput -detached \
-boot $DOG_HOME/priv/dog_trainer_${ERL_VER} \
-env $ENV_VARS \
-sname $NODE -config ${DOG_HOME}/config/sys.config -s dog_trainer_app
}
console() {
echo "Starting dog_trainer in console mode - version ${ERL_VER} ${ERL}"
NODE="dog_trainer@${HOST}"
${ERL} 128 +P 4194304 +A 128 \
-boot ${DOG_HOME}/priv/dog_trainer_${ERL_VER} \
-env ${ENV_VARS} \
-sname ${NODE} -config ${DOG_HOME}/config/sys.config -s dog_trainer_app
}
stop() {
echo "Stopping dog_trainer"
NODE="dog_trainerctl@${HOST}"
$ERL -noshell \
-boot ${DOG_HOME}/priv/dog_trainer_${ERL_VER} \
-sname $NODE -s dog_trainer_app stop
}
debug() {
NODE="dog_trainerdebug@$HOST"
$ERL -sname ${NODE} \
-boot $DOG_HOME/priv/dog_trainer_${ERL_VER} \
-remsh dog_trainer@${HOST}
}
rebar_eunit() {
NODE="dog_trainer@${HOST}"
ERL_FLAGS="-config config/sys.config -sname $NODE" ./rebar3 eunit
}
rebar_shell() {
NODE="dog_trainer@${HOST}"
ERL_FLAGS="-config config/sys.config -sname $NODE" ./rebar3 shell
}
rebar_auto() {
NODE="dog_trainer@${HOST}"
ERL_FLAGS="-config config/sys.config -sname $NODE" ./rebar3 auto
}
usage() {
echo "dog_trainer.sh start"
echo "dog_trainer.sh stop"
echo "dog_trainer.sh debug"
echo "dog_trainer.sh console"
echo "dog_trainer.sh rebar_eunit"
echo "dog_trainer.sh rebar_shell"
echo "dog_trainer.sh rebar_auto"
echo -n
exit 1
}
if [ $# -eq 1 ]
then
case $1 in
"start" ) start ;;
"stop" ) stop ;;
"debug" ) debug ;;
"console" ) console ;;
"rebar_eunit" ) rebar_eunit ;;
"rebar_shell" ) rebar_shell ;;
"rebar_auto" ) rebar_auto ;;
* ) echo "Invalid command: $1"; usage ;;
esac
else
usage
fi