plugins.config, ERL_LIBS

This commit is contained in:
Feng Lee 2015-04-22 15:03:14 +08:00
parent 1b7f6c180e
commit 2faf26a372
7 changed files with 130 additions and 5 deletions

View File

@ -2,6 +2,16 @@
emqttd ChangeLog emqttd ChangeLog
================== ==================
0.7.0-alpha (2015-04-20)
-------------------------
OK Trace API
Plugin Load/Unload
WebSocket
0.6.1-alpha (2015-04-20) 0.6.1-alpha (2015-04-20)
------------------------- -------------------------

View File

@ -1,5 +1,5 @@
LDAP Auth LDAP Auth
MySQL Auth MySQL Auth
Admin Console Dashboard
AMQP AMQP

View File

@ -1,7 +1,7 @@
{application, emqttd_plugin_demo, {application, emqttd_plugin_demo,
[ [
{description, ""}, {description, "emqttd demo plugin"},
{vsn, "1"}, {vsn, "0.1"},
{registered, []}, {registered, []},
{applications, [ {applications, [
kernel, kernel,

View File

@ -0,0 +1,45 @@
%%%-----------------------------------------------------------------------------
%%% @Copyright (C) 2012-2015, Feng Lee <feng@emqtt.io>
%%%
%%% Permission is hereby granted, free of charge, to any person obtaining a copy
%%% of this software and associated documentation files (the "Software"), to deal
%%% in the Software without restriction, including without limitation the rights
%%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
%%% copies of the Software, and to permit persons to whom the Software is
%%% furnished to do so, subject to the following conditions:
%%%
%%% The above copyright notice and this permission notice shall be included in all
%%% copies or substantial portions of the Software.
%%%
%%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
%%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
%%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
%%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
%%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
%%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
%%% SOFTWARE.
%%%-----------------------------------------------------------------------------
%%% @doc
%%% emqttd demo acl module.
%%%
%%% @end
%%%-----------------------------------------------------------------------------
-module(emqttd_plugin_demo_acl).
-author("Feng Lee <feng@emqtt.io>").
-include_lib("emqttd/include/emqttd.hrl").
-behaviour(emqttd_acl_mod).
%% ACL callbacks
-export([init/1, check_acl/2, reload_acl/1, description/0]).
init(Opts) -> {ok, Opts}.
check_acl({_Client, _PubSub, _Topic}, _State) -> ignore.
reload_acl(_State) -> ok.
description() -> "Demo ACL Module".

View File

@ -10,7 +10,10 @@
%% =================================================================== %% ===================================================================
start(_StartType, _StartArgs) -> start(_StartType, _StartArgs) ->
emqttd_plugin_demo_sup:start_link(). {ok, Sup} = emqttd_plugin_demo_sup:start_link(),
emqttd_access_control:register_mod(auth, emqttd_plugin_demo_auth, []),
emqttd_access_control:register_mod(acl, emqttd_plugin_demo_acl, []),
{ok, Sup}.
stop(_State) -> stop(_State) ->
ok. ok.

View File

@ -0,0 +1,42 @@
%%%-----------------------------------------------------------------------------
%%% @Copyright (C) 2012-2015, Feng Lee <feng@emqtt.io>
%%%
%%% Permission is hereby granted, free of charge, to any person obtaining a copy
%%% of this software and associated documentation files (the "Software"), to deal
%%% in the Software without restriction, including without limitation the rights
%%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
%%% copies of the Software, and to permit persons to whom the Software is
%%% furnished to do so, subject to the following conditions:
%%%
%%% The above copyright notice and this permission notice shall be included in all
%%% copies or substantial portions of the Software.
%%%
%%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
%%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
%%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
%%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
%%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
%%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
%%% SOFTWARE.
%%%-----------------------------------------------------------------------------
%%% @doc
%%% emqttd demo auth module.
%%%
%%% @end
%%%-----------------------------------------------------------------------------
-module(emqttd_plugin_demo_auth).
-author("Feng Lee <feng@emqtt.io>").
-include_lib("emqttd/include/emqttd.hrl").
-behaviour(emqttd_auth_mod).
-export([init/1, check/3, description/0]).
init(Opts) -> {ok, Opts}.
check(_Client, _Password, _Opts) -> ignore.
description() -> "Demo authentication module".

View File

@ -20,6 +20,8 @@ RUNNER_BASE_DIR={{runner_base_dir}}
RUNNER_ETC_DIR={{runner_etc_dir}} RUNNER_ETC_DIR={{runner_etc_dir}}
RUNNER_LIB_DIR={{platform_lib_dir}} RUNNER_LIB_DIR={{platform_lib_dir}}
RUNNER_LOG_DIR={{runner_log_dir}} RUNNER_LOG_DIR={{runner_log_dir}}
RUNNER_PLUGINS_DIR=$RUNNER_BASE_DIR/plugins
# Note the trailing slash on $PIPE_DIR/ # Note the trailing slash on $PIPE_DIR/
PIPE_DIR={{pipe_dir}} PIPE_DIR={{pipe_dir}}
RUNNER_USER={{runner_user}} RUNNER_USER={{runner_user}}
@ -139,6 +141,13 @@ case "$1" in
echo $RES echo $RES
exit 1 exit 1
fi fi
# Sanity check the plugins.config file
RES=`$NODETOOL_LITE chkconfig $RUNNER_ETC_DIR/plugins.config`
if [ $? != 0 ]; then
echo "Error reading $RUNNER_ETC_DIR/plugins.config"
echo $RES
exit 1
fi
HEART_COMMAND="$RUNNER_SCRIPT_DIR/$SCRIPT start" HEART_COMMAND="$RUNNER_SCRIPT_DIR/$SCRIPT start"
export HEART_COMMAND export HEART_COMMAND
mkdir -p $PIPE_DIR mkdir -p $PIPE_DIR
@ -256,17 +265,26 @@ case "$1" in
echo $RES echo $RES
exit 1 exit 1
fi fi
# Sanity check the plugins.config file
RES=`$NODETOOL_LITE chkconfig $RUNNER_ETC_DIR/plugins.config`
if [ $? != 0 ]; then
echo "Error reading $RUNNER_ETC_DIR/plugins.config"
echo $RES
exit 1
fi
# Setup beam-required vars # Setup beam-required vars
ROOTDIR=$RUNNER_BASE_DIR ROOTDIR=$RUNNER_BASE_DIR
ERL_LIBS=$ROOTDIR/plugins
BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
EMU=beam EMU=beam
PROGNAME=`echo $0 | sed 's/.*\///'` PROGNAME=`echo $0 | sed 's/.*\///'`
CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$SCRIPT \ CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$SCRIPT \
-embedded -config $RUNNER_ETC_DIR/app.config \ -embedded -config $RUNNER_ETC_DIR/app.config -config $RUNNER_ETC_DIR/plugins.config \
-pa $RUNNER_LIB_DIR/basho-patches \ -pa $RUNNER_LIB_DIR/basho-patches \
-args_file $RUNNER_ETC_DIR/vm.args -- ${1+"$@"}" -args_file $RUNNER_ETC_DIR/vm.args -- ${1+"$@"}"
export EMU export EMU
export ROOTDIR export ROOTDIR
export ERL_LIBS
export BINDIR export BINDIR
export PROGNAME export PROGNAME
@ -287,6 +305,13 @@ case "$1" in
echo $RES echo $RES
exit 1 exit 1
fi fi
# Sanity check the plugins.config file
RES=`$NODETOOL_LITE chkconfig $RUNNER_ETC_DIR/plugins.config`
if [ $? != 0 ]; then
echo "Error reading $RUNNER_ETC_DIR/plugins.config"
echo $RES
exit 1
fi
echo "config is OK" echo "config is OK"
;; ;;
escript) escript)