Commit 30aba7af by Chavee Issariyapat

restructure

parent 693db537
......@@ -17,15 +17,18 @@ RUN apk --no-cache --update --available upgrade && \
install -d -o vernemq -g vernemq /vernemq
# Defaults
ENV DOCKER_VERNEMQ_KUBERNETES_LABEL_SELECTOR="app=vernemq" \
DOCKER_VERNEMQ_LOG__CONSOLE=console \
PATH="/vernemq/bin:$PATH" \
VERNEMQ_VERSION="1.11.1"
ENV PATH="/vernemq/bin:$PATH" \
VERNEMQ_VERSION="1.12.5"
WORKDIR /vernemq
COPY --chown=10000:10000 files/vm.args /etc/vernemq/vm.args
COPY --chown=10000:10000 files/_vernemq.conf /etc/vernemq/vernemq.conf
COPY --chown=10000:10000 bin/vernemq.sh /usr/sbin/start_vernemq
COPY --chown=10000:10000 files/vm.args /vernemq/etc/vm.args
COPY --chown=10000:10000 bin/setapikey.sh /usr/sbin/setapikey.sh
COPY --chown=10000:10000 bin/rand_cluster_node.escript /var/lib/vernemq/rand_cluster_node.escript
RUN chown -R 10000:10000 /vernemq && \
ln -s /vernemq/etc /etc/vernemq && \
......@@ -39,15 +42,16 @@ RUN chown -R 10000:10000 /vernemq && \
# 44053 VerneMQ Message Distribution
# 4369 EPMD - Erlang Port Mapper Daemon
# 8888 Prometheus Metrics
# 8008 HTTP API
# 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 Specific Distributed Erlang Port Range
EXPOSE 1883 8883 8080 44053 4369 8888 \
EXPOSE 1883 8883 8008 44053 4369 8888 8008\
9100 9101 9102 9103 9104 9105 9106 9107 9108 9109
VOLUME ["/vernemq/log", "/vernemq/data", "/vernemq/etc"]
HEALTHCHECK CMD curl -s -f http://localhost:8888/health || false
# HEALTHCHECK CMD curl -s -f http://localhost:8888/health || false
USER vernemq
CMD ["start_vernemq"]
# VerneMQ
Original VerneMQ customized with a NEXPIE opinionated webhook and configuration to be used as a based of IoT microservices.
%% -*- erlang -*-
main([ThisNode]) ->
code:add_paths(filelib:wildcard("/usr/lib/vernemq/lib/*/ebin")),
FileName = "/var/lib/vernemq/meta/peer_service/cluster_state",
case filelib:is_regular(FileName) of
true ->
{ok, Bin} = file:read_file(FileName),
{ok, State} = riak_dt_orswot:from_binary(Bin),
AThisNode = list_to_atom(ThisNode),
TargetNodes = riak_dt_orswot:value(State) -- [AThisNode],
L = lists:foldl(
fun(N, Acc) ->
Acc ++ atom_to_list(N) ++ "\n"
end, "", TargetNodes),
io:format(L);
false ->
io:format("")
end.
#!/bin/sh
# retry checking until vernemq start responding
while true ; do
vmq-admin cluster show > output.tmp
VAR0=$(cat output.tmp | grep -A 3 "+----")
echo "wating ............"
#echo $VAR0
if [ "$VAR0" ]; then
rm output.tmp
break
fi
sleep 3
done
# retry adding api key until 'Done'
echo "vernemq is ready"
while true ; do
vmq-admin api-key add key=$DEVICEBROKER_VMQ_APIKEY > output.tmp
VAR0=$(cat output.tmp | grep -A 3 "Done")
A0=$(echo $VAR0 | awk '{printf $1}')
echo $A0
if [ "$A0" = "Done" ]; then
rm output.tmp
break
fi
sleep 3
done
#register webhooks
#echo "register: auth_on_register"
#vmq-admin webhooks register hook=auth_on_register endpoint=http://localhost:40000/authreg --base64payload=true
#echo "register: auth_on_publish"
#vmq-admin webhooks register hook=auth_on_publish endpoint=http://localhost:40000/authpub --base64payload=true
#echo "register: auth_on_subscribe"
#vmq-admin webhooks register hook=auth_on_subscribe endpoint=http://localhost:40000/authsub --base64payload=true
#echo "register: on_deliver"
#vmq-admin webhooks register hook=on_deliver endpoint=http://localhost:40000/ondeliver --base64payload=true
#echo "register: on_client_offline"
#vmq-admin webhooks register hook=on_client_offline endpoint=http://localhost:40000/onoff --base64payload=true
#echo "register: on_client_gone"
#vmq-admin webhooks register hook=on_client_gone endpoint=http://localhost:40000/ongone --base64payload=true
##echo "register: on_publish"
##vmq-admin webhooks register hook=on_publish endpoint=http://localhost:40000/onpub --base64payload=true
#echo "register: on_unsubscribe"
#vmq-admin webhooks register hook=on_unsubscribe endpoint=http://localhost:40000/onunsub --base64payload=true
echo "complete"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment