-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy patheboshctl
executable file
·169 lines (141 loc) · 3.2 KB
/
eboshctl
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/sh
COMMAND=$1
ERL=`which erl`
ERL_OPTS="-pa deps/*/ebin -pa ebin"
EXEC="$ERL $ERL_OPTS"
## erlang cookie and node name
COOKIE_OPTS=`grep '^-setcookie' vm.args`
NODE_OPTS=`egrep '^-s?name' vm.args | cut -f1 -d' '`
NODE=`egrep '^-s?name' vm.args | cut -f2 -d' '`
ERL_INTERFACE_DIR=/usr/local/lib/erlang/lib/erl_interface-3.7.5
ERL_INTERFACE_LDFLAGS="-lerl_interface -lei"
## nginx ebosh module
NGX_SRC_DIR=/Users/abhinavsingh/Documents/nginx-1.2.0
NGX_EBOSH_SRC_DIR=/Users/abhinavsingh/git/ebosh/ngx_http_ebosh_module/src
DIALYZER=`which dialyzer`
PLT_PATH=.ebosh_dialyzer.plt
REBAR=./rebar
REBAR_URL=http://cloud.github.com/downloads/basho/rebar/rebar
case $COMMAND in
start)
echo "starting ebosh ..."
$EXEC \
-args_file vm.args \
-config ebosh.config \
-s ebosh \
-noshell \
-detached
;;
console)
echo "starting ebosh and attaching to debug console..."
$EXEC \
-args_file vm.args \
-config ebosh.config \
-s ebosh
;;
restart)
$0 stop
$0 start
;;
stop)
echo "stopping ebosh ..."
$EXEC \
$NODE_OPTS "stop-$NODE" \
$COOKIE_OPTS \
-eval "rpc:call('$NODE', init, stop, [])" \
-noshell \
-hidden \
-s init stop
;;
debug)
echo "entering ebosh debug console ... press CNTR+C, CNTR+C to exit"
$EXEC \
$NODE_OPTS "attach-$NODE" \
$COOKIE_OPTS \
-remsh $NODE \
-hidden
;;
ping)
echo "pinging $NODE ..."
$EXEC \
$NODE_OPTS "ping-$NODE" \
$COOKIE_OPTS \
-eval \
"case net_adm:ping('$NODE') of \
pong -> io:fwrite(\"running~n\",[]); \
pang -> io:fwrite(\"not running~n\",[]) \
end" \
-noshell \
-hidden \
-s init stop
;;
compile)
$REBAR compile
$0 compile-mod
;;
clean)
$REBAR clean
;;
test)
$REBAR skip_deps=true eunit
;;
build-plt)
$DIALYZER \
--build_plt \
--output_plt $PLT_PATH \
--apps kernel stdlib crypto ssl inets exmpp deps/*/ebin
;;
dialyze)
$DIALYZER --src src \
--plt $PLT_PATH \
-Werror_handling -Wrace_conditions -Wunmatched_returns -Wunderspecs
;;
doc)
echo "generating docs"
$EXEC \
$NODE_OPTS "doc-$NODE" \
$COOKIE_OPTS \
-eval \
"edoc:application( \
ebosh, \
\".\", \
[{doclet, edown_doclet}, \
{app_default, \"http://www.erlang.org/doc/man\"}, \
{top_level_readme, {\"./README.md\", \"http://github.com/abhinavsingh/ebosh\"}} \
])" \
-noshell \
-hidden \
-s init stop
;;
get-deps)
$REBAR get-deps
;;
update-deps)
$REBAR update-deps
;;
rebar)
wget -q -O $REBAR $REBAR_URL
chmod u+x $REBAR
;;
## compile mod_ebosh for ejabberd
compile-mod)
echo "compiling mod_ebosh"
erlc -I/lib/ejabberd/include -I/lib/ejabberd/include/web -Iinclude -pa /lib/ejabberd/ebin -o ebin/ mod_ebosh/mod_ebosh.erl
;;
## install mod_ebosh
install-mod)
cp ebin/mod_ebosh.beam /lib/ejabberd/ebin/
;;
compile-nginx)
cd $NGX_SRC_DIR
./configure \
--add-module=$NGX_EBOSH_SRC_DIR \
--with-ld-opt="-I$ERL_INTERFACE_DIR/include -L$ERL_INTERFACE_DIR/lib $ERL_INTERFACE_LDFLAGS" \
--with-cc-opt="-I$ERL_INTERFACE_DIR/include -L$ERL_INTERFACE_DIR/lib"
make
;;
*)
echo "Usage: $0 {start|console|restart|stop|debug|ping|compile|clean|test|doc|get-deps|update-deps|rebar|compile-mod|install-mod}"
exit 1
esac
exit 0