Explorar el Código

build: check mnesia compatibility when generating mria config

Zaiming (Stone) Shi hace 2 años
padre
commit
ed0d0b9787
Se han modificado 1 ficheros con 14 adiciones y 3 borrados
  1. 14 3
      dev

+ 14 - 3
dev

@@ -206,10 +206,21 @@ make_erlang_args() {
 }
 }
 
 
 call_hocon() {
 call_hocon() {
+    local args erl_code
     args="$(make_erlang_args "$@")"
     args="$(make_erlang_args "$@")"
-    erl -noshell \
-        -eval "{ok, _} = application:ensure_all_started(hocon), \
-               ok = hocon_cli:main([$args]), init:stop()."
+    erl_code="
+        {ok, _} = application:ensure_all_started(hocon), \
+        try
+          mnesia_hook:module_info()
+        catch _:_->
+          io:format(standard_error, \"Force setting DB backend to 'mnesia', and 'role' to 'core'~n\", []),
+          os:putenv(\"EMQX_NODE__DB_BACKEND\", \"mnesia\"),
+          os:putenv(\"EMQX_NODE__DB_ROLE\", \"core\")
+        end,
+        ok = hocon_cli:main([$args]),
+        init:stop().
+    "
+    erl -noshell -eval "$erl_code"
 }
 }
 
 
 # Function to generate app.config and vm.args
 # Function to generate app.config and vm.args