Bläddra i källkod

Merge branch 'master' into dev-feng

Feng 10 år sedan
förälder
incheckning
35bc96807e
9 ändrade filer med 96 tillägg och 48 borttagningar
  1. 14 0
      CHANGELOG.md
  2. 1 1
      plugins/emqttd_dashboard
  3. 6 0
      rel/files/emqttd
  4. 12 1
      rel/files/emqttd.cmd
  5. 50 40
      rel/files/start_erl.cmd
  6. 0 5
      rel/files/vm.args
  7. 1 0
      rel/reltool.config
  8. 1 1
      src/emqttd.app.src
  9. 11 0
      src/emqttd_http.erl

+ 14 - 0
CHANGELOG.md

@@ -2,6 +2,20 @@
 emqttd ChangeLog
 ==================
 
+0.10.2-beta (2015-08-26)
+-------------------------
+
+Improve: issue#257 - After the node name changed, the broker cannot restart for mnesia schema error.
+
+
+0.10.1-beta (2015-08-25)
+-------------------------
+
+Bugfix: issue#259 - when clustered the emqttd_dashboard port is close, and the 'emqttd' application cannot stop normally.
+
+Feature: issue#262 - Add 'http://host:8083/mqtt/status' Page for health check
+
+
 0.10.0-beta (2015-08-20)
 -------------------------
 

+ 1 - 1
plugins/emqttd_dashboard

@@ -1 +1 @@
-Subproject commit c87d9c4580e568917b4b026c809becf2cccd469e
+Subproject commit edbb6dc0862973137b056248efb5940d003d75be

+ 6 - 0
rel/files/emqttd

@@ -20,6 +20,7 @@ RUNNER_BASE_DIR={{runner_base_dir}}
 RUNNER_ETC_DIR={{runner_etc_dir}}
 RUNNER_LIB_DIR={{platform_lib_dir}}
 RUNNER_LOG_DIR={{runner_log_dir}}
+RUNNER_DATA_DIR=$RUNNER_BASE_DIR/data
 RUNNER_PLUGINS_DIR=$RUNNER_BASE_DIR/plugins
 
 # Note the trailing slash on $PIPE_DIR/
@@ -72,6 +73,8 @@ if [ -z "$NAME_ARG" ]; then
     echo "vm.args needs to have either -name or -sname parameter."
     exit 1
 fi
+NAME_ARR=(${NAME_ARG// / })
+NODE_NAME=${NAME_ARR[1]}
 
 # Extract the target cookie
 COOKIE_ARG=`grep '^\-setcookie' $RUNNER_ETC_DIR/vm.args`
@@ -264,9 +267,12 @@ case "$1" in
         BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
         EMU=beam
         PROGNAME=`echo $0 | sed 's/.*\///'`
+        # Setup Mnesia Dir
+        MNESIA_DIR="$RUNNER_DATA_DIR/mnesia/$NODE_NAME"
         CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$SCRIPT \
             -embedded -config $RUNNER_ETC_DIR/emqttd.config \
             -pa $RUNNER_LIB_DIR/basho-patches \
+            -mnesia dir "\"${MNESIA_DIR}\"" \
             -args_file $RUNNER_ETC_DIR/vm.args -- ${1+"$@"}"
         export EMU
         export ROOTDIR

+ 12 - 1
rel/files/emqttd.cmd

@@ -1,4 +1,6 @@
+@echo off
 @setlocal
+@setlocal enabledelayedexpansion
 
 @set node_name=emqttd
 
@@ -69,7 +71,16 @@
 @goto :EOF
 
 :console
-@start "%node_name% console" %werl% -boot "%node_boot_script%" -config "%sys_config%" -args_file "%vm_args%" -sname %node_name%
+set dest_path=%~dp0
+cd /d !dest_path!..\plugins
+set current_path=%cd%
+set plugins=
+for /d %%P in (*) do (
+set "plugins=!plugins!!current_path!\%%P\ebin "
+)
+cd /d %node_root%
+
+@start "%node_name% console" %werl% -boot "%node_boot_script%" -config "%sys_config%" -args_file "%vm_args%" -sname %node_name% -pa %plugins%
 @goto :EOF
 
 :query

+ 50 - 40
rel/files/start_erl.cmd

@@ -1,40 +1,50 @@
-@setlocal
-
-@rem Parse arguments. erlsrv.exe prepends erl arguments prior to first ++.
-@rem Other args are position dependent.
-@set args="%*"
-@for /F "delims=++ tokens=1,2,3" %%I in (%args%) do @(
-    @set erl_args=%%I
-    @call :set_trim node_name %%J
-    @rem Trim spaces from the left of %%K (node_root), which may have spaces inside
-    @for /f "tokens=* delims= " %%a in ("%%K") do @set node_root=%%a
-)
-
-@set releases_dir=%node_root%\releases
-
-@rem parse ERTS version and release version from start_erl.dat
-@for /F "usebackq tokens=1,2" %%I in ("%releases_dir%\start_erl.data") do @(
-    @call :set_trim erts_version %%I
-    @call :set_trim release_version %%J
-)
-
-@set erl_exe="%node_root%\erts-%erts_version%\bin\erl.exe"
-@set boot_file="%releases_dir%\%release_version%\%node_name%"
-
-@if exist "%releases_dir%\%release_version%\sys.config" (
-    @set app_config="%releases_dir%\%release_version%\sys.config"
-) else (
-    @set app_config="%node_root%\etc\emqttd.config"
-)
-
-@if exist "%releases_dir%\%release_version%\vm.args" (
-    @set vm_args="%releases_dir%\%release_version%\vm.args"
-) else (
-    @set vm_args="%node_root%\etc\vm.args"
-)
-
-@%erl_exe% %erl_args% -boot %boot_file% -config %app_config% -args_file %vm_args%
-
-:set_trim
-@set %1=%2
-@goto :EOF
+@setlocal
+@echo off
+@setlocal enabledelayedexpansion
+
+@rem Parse arguments. erlsrv.exe prepends erl arguments prior to first ++.
+@rem Other args are position dependent.
+@set args="%*"
+@for /F "delims=++ tokens=1,2,3" %%I in (%args%) do @(
+    @set erl_args=%%I
+    @call :set_trim node_name %%J
+    @rem Trim spaces from the left of %%K (node_root), which may have spaces inside
+    @for /f "tokens=* delims= " %%a in ("%%K") do @set node_root=%%a
+)
+
+@set releases_dir=%node_root%\releases
+
+@rem parse ERTS version and release version from start_erl.dat
+@for /F "usebackq tokens=1,2" %%I in ("%releases_dir%\start_erl.data") do @(
+    @call :set_trim erts_version %%I
+    @call :set_trim release_version %%J
+)
+
+@set erl_exe="%node_root%\erts-%erts_version%\bin\erl.exe"
+@set boot_file="%releases_dir%\%release_version%\%node_name%"
+
+@if exist "%releases_dir%\%release_version%\sys.config" (
+    @set app_config="%releases_dir%\%release_version%\sys.config"
+) else (
+    @set app_config="%node_root%\etc\emqttd.config"
+)
+
+@if exist "%releases_dir%\%release_version%\vm.args" (
+    @set vm_args="%releases_dir%\%release_version%\vm.args"
+) else (
+    @set vm_args="%node_root%\etc\vm.args"
+)
+
+set dest_path=%~dp0
+cd /d !dest_path!..\plugins
+set current_path=%cd%
+set plugins=
+for /d %%P in (*) do (
+set "plugins=!plugins!!current_path!\%%P\ebin "
+)
+cd /d %node_root%
+@%erl_exe% %erl_args% -boot %boot_file% -config %app_config% -args_file %vm_args% -pa %plugins%
+
+:set_trim
+@set %1=%2
+@goto :EOF

+ 0 - 5
rel/files/vm.args

@@ -6,11 +6,6 @@
 ## Cookie for distributed erlang
 -setcookie emqttdsecretcookie
 
-##-------------------------------------------------------------------------
-## Mnesia dir. NOTICE: quote the dir with '" "'
-##-------------------------------------------------------------------------
--mnesia dir '"data/mnesia"'
-
 ##-------------------------------------------------------------------------
 ## Flags
 ##-------------------------------------------------------------------------

+ 1 - 0
rel/reltool.config

@@ -73,6 +73,7 @@
            {mkdir, "etc/"},
            {mkdir, "etc/ssl/"},
            {mkdir, "data/"},
+           {mkdir, "data/mnesia"},
            {mkdir, "plugins/"},
            {copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"},
            {template, "files/nodetool", "\{\{erts_vsn\}\}/bin/nodetool"},

+ 1 - 1
src/emqttd.app.src

@@ -1,7 +1,7 @@
 {application, emqttd,
  [
   {description, "Erlang MQTT Broker"},
-  {vsn, "0.10.1"},
+  {vsn, "0.10.2"},
   {modules, []},
   {registered, []},
   {applications, [kernel,

+ 11 - 0
src/emqttd_http.erl

@@ -39,6 +39,17 @@
 handle_request(Req) ->
     handle_request(Req:get(method), Req:get(path), Req).
 
+handle_request('GET', "/mqtt/status", Req) ->
+    {InternalStatus, _ProvidedStatus} = init:get_status(),
+    AppStatus =
+    case lists:keysearch(emqttd, 1, application:which_applications()) of
+        false         -> not_running;
+        {value, _Ver} -> running
+    end,
+    Status = io_lib:format("Node ~s is ~s~nemqttd is ~s~n",
+                            [node(), InternalStatus, AppStatus]),
+    Req:ok({"text/plain", iolist_to_binary(Status)});
+
 %%------------------------------------------------------------------------------
 %% HTTP Publish API
 %%------------------------------------------------------------------------------