Build-Depends: debhelper (>= 9~),
dh-systemd (>= 1.5),
erlang-dev,
- erlang-nox (>= 1:13.b.3),
- erlang-src (>= 1:13.b.3),
+ erlang-nox (>= 1:18.1),
+ erlang-src (>= 1:18.1),
python-simplejson,
rsync,
unzip,
Package: rabbitmq-server
Architecture: all
Depends: adduser,
- erlang-nox (>= 1:13.b.3) | esl-erlang,
+ erlang-nox (>= 1:18.1),
+ erlang-base-hipe (>= 1:18.1),
logrotate,
${misc:Depends}
Description: AMQP server written in Erlang
chown -R rabbitmq:rabbitmq /var/lib/rabbitmq
chown -R rabbitmq:rabbitmq /var/log/rabbitmq
+HIPE_DIRECTORY=/var/lib/rabbitmq/native-code
+
+ensure_erlang_cookie () {
+ HOME=/root/ erl -noinput -sname root-cookie-ensure-$$ -s init stop
+ echo "$(cat $HOME/.erlang.cookie)"
+}
+
+ensure_hipe_starter () {
+ local cookie="$1"
+ HOME=/root \
+ RABBITMQ_NODENAME=rabbit-hipe-compiler@localhost \
+ RABBITMQ_NODE_ONLY=true \
+ RABBITMQ_NODE_PORT=65000 \
+ RABBITMQ_DIST_PORT=65001 \
+ RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-cookie \"$cookie\"" \
+ /usr/lib/rabbitmq/bin/rabbitmq-server -detached
+}
+
+hipe_starter_eval () {
+ local cookie="$1"
+ local code="$2"
+ HOME=/root \
+ RABBITMQ_NODENAME=rabbit-hipe-compiler@localhost \
+ RABBITMQ_CTL_ERL_ARGS="-cookie \"$cookie\"" \
+ /usr/lib/rabbitmq/bin/rabbitmqctl eval "$code"
+}
+
+hipe_compile () {
+ local retry_no
+ local cookie
+
+ rm -rf ${HIPE_DIRECTORY}
+ mkdir -p ${HIPE_DIRECTORY}
+
+ pkill -f rabbit-hipe-compiler || true
+
+ cookie="$(ensure_erlang_cookie)"
+ ensure_hipe_starter "$cookie"
+
+ for retry_no in $(seq 1 10); do
+ if hipe_starter_eval "$cookie" "1." > /dev/null 2>&1 ; then
+ break
+ fi
+ done
+
+ # Don't check whether we've found running node in the loop above - following eval call will catch
+ # this error naturally.
+ hipe_starter_eval "$cookie" "
+application:load(rabbit),
+application:load(rabbit_common),
+{ok, Mods} = application:get_env(rabbit, hipe_modules),
+ModsToDump = [ Mod || Mod <- Mods, Mod:module_info(native) =:= false ],
+[ begin
+ {M, BeamCode, _} = code:get_object_code(M),
+ BeamName = \"${HIPE_DIRECTORY}/\" ++ atom_to_list(M) ++ \".beam\",
+ {ok, {Architecture, NativeCode}} = hipe:compile(M, [], BeamCode, [o3]),
+ {ok, _, Chunks0} = beam_lib:all_chunks(BeamCode),
+ ChunkName = hipe_unified_loader:chunk_name(Architecture),
+ Chunks1 = lists:keydelete(ChunkName, 1, Chunks0),
+ Chunks = Chunks1 ++ [{ChunkName,NativeCode}],
+ {ok, BeamPlusNative} = beam_lib:build_module(Chunks),
+ file:write_file(BeamName, BeamPlusNative),
+ M
+ end
+ || M <- ModsToDump ].
+"
+
+ pkill -f rabbit-hipe-compiler || true
+}
+
case "$1" in
configure)
if [ -f /etc/rabbitmq/rabbitmq.conf ] && \
[ ! -f /etc/rabbitmq/rabbitmq-env.conf ]; then
mv /etc/rabbitmq/rabbitmq.conf /etc/rabbitmq/rabbitmq-env.conf
fi
+ hipe_compile
;;
abort-upgrade|abort-remove|abort-deconfigure)