Compare commits
114 Commits
master
...
build-with
Author | SHA1 | Date |
---|---|---|
![]() |
ccd8a2f9d7 | |
![]() |
757a944ade | |
![]() |
eaa05d7227 | |
![]() |
9edb7ac3ed | |
![]() |
05c638219c | |
![]() |
51bd361b16 | |
![]() |
2e5596f6ee | |
![]() |
f6d0159371 | |
![]() |
23d72b334e | |
![]() |
0f57fb9599 | |
![]() |
5d31c7eb6b | |
![]() |
44446bb762 | |
![]() |
c5241670e0 | |
![]() |
f936aba6b7 | |
![]() |
295b1312be | |
![]() |
c6ea575d35 | |
![]() |
36fd7369e0 | |
![]() |
2b46e16d74 | |
![]() |
7a4edc0104 | |
![]() |
c1b737a9b2 | |
![]() |
2ded7fbe8c | |
![]() |
4eb966549e | |
![]() |
70491aee07 | |
![]() |
bc99d5c1a6 | |
![]() |
fdf439bc7b | |
![]() |
d796f815d7 | |
![]() |
b8de05891e | |
![]() |
74b63f7d68 | |
![]() |
2def7e4ac2 | |
![]() |
ddcf73f465 | |
![]() |
cc5b995cf2 | |
![]() |
ab201625c3 | |
![]() |
1c144d7d67 | |
![]() |
92d5f4b3b2 | |
![]() |
54223e4fe6 | |
![]() |
0531a1925c | |
![]() |
1b56fba471 | |
![]() |
147e2e911f | |
![]() |
1d24e46ece | |
![]() |
d78fbc5a8a | |
![]() |
595598916f | |
![]() |
cde614aad8 | |
![]() |
7364e821b8 | |
![]() |
2b7e93f55f | |
![]() |
b0e579fcd8 | |
![]() |
15205942e0 | |
![]() |
c9a0c37dbb | |
![]() |
d2fc66f436 | |
![]() |
6697b9fa42 | |
![]() |
2f2a093150 | |
![]() |
efca545d3d | |
![]() |
1c22c0d596 | |
![]() |
c0364ad5a2 | |
![]() |
6d9b3ed341 | |
![]() |
494bac419d | |
![]() |
835539364e | |
![]() |
4b8bd8e562 | |
![]() |
fc1e4893a8 | |
![]() |
257bc353a4 | |
![]() |
0d38b75bb2 | |
![]() |
6ef68f8e2c | |
![]() |
fca7fd755d | |
![]() |
760d896d9d | |
![]() |
69126fede6 | |
![]() |
887544c3c1 | |
![]() |
d224687de2 | |
![]() |
e182a5f38c | |
![]() |
1a473bb73b | |
![]() |
3e8b9ff76a | |
![]() |
22858eb845 | |
![]() |
814623edae | |
![]() |
75c9267473 | |
![]() |
ae71bdc0fe | |
![]() |
fd482e2ec0 | |
![]() |
591b704f65 | |
![]() |
dbe45d9d6f | |
![]() |
783a10c5a1 | |
![]() |
6a4b437446 | |
![]() |
d0b54ac365 | |
![]() |
b76334ea01 | |
![]() |
0312f07b11 | |
![]() |
93532615c1 | |
![]() |
2d25e895a8 | |
![]() |
f20d5b5395 | |
![]() |
ddb79f51ae | |
![]() |
7e2c035562 | |
![]() |
df1cbb0bab | |
![]() |
e3437d5b9e | |
![]() |
c14319e5bd | |
![]() |
188f44ad50 | |
![]() |
13e146d1ee | |
![]() |
5e812a1add | |
![]() |
7a7cccb337 | |
![]() |
69673613d6 | |
![]() |
22b2a3902e | |
![]() |
1ef7f4e2a0 | |
![]() |
5dd7f53662 | |
![]() |
19e92d7936 | |
![]() |
3c4430c252 | |
![]() |
2c6e8204b8 | |
![]() |
e4eeb585cb | |
![]() |
25f03ed87a | |
![]() |
d33465052f | |
![]() |
bd3760d5c7 | |
![]() |
4c1e03bbcd | |
![]() |
ef4c30b2fd | |
![]() |
9fc635826c | |
![]() |
e83217fb09 | |
![]() |
6905eb4ac1 | |
![]() |
c940ab9e0a | |
![]() |
e40148a6dd | |
![]() |
ba002bb1b5 | |
![]() |
ed34783dd7 | |
![]() |
8ec83705ad |
|
@ -0,0 +1,5 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["mix.exs", "config/*.exs"],
|
||||
subdirectories: ["apps/*"]
|
||||
]
|
|
@ -0,0 +1,4 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
|
@ -24,4 +24,5 @@
|
|||
|
||||
%% NOTE: This version number should be manually bumped for each release
|
||||
|
||||
-define(EMQX_RELEASE, "5.0-beta.2").
|
||||
%% FIXME!!!
|
||||
-define(EMQX_RELEASE, "5.0-beta.2-3fdc075b").
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
defmodule EMQX.MixProject do
|
||||
use Mix.Project
|
||||
Code.require_file("../../lib/emqx/mix/common.ex")
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx,
|
||||
version: "5.0.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
mod: {:emqx_app, []},
|
||||
applications: EMQX.Mix.Common.erl_apps(:emqx),
|
||||
extra_applications: [:logger, :os_mon, :syntax_tools]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
# {:gproc, "0.9.0"},
|
||||
# {:recon, "2.5.2"},
|
||||
{:cowboy, github: "emqx/cowboy", tag: "2.8.3"},
|
||||
{:esockd, github: "emqx/esockd", tag: "5.9.0"},
|
||||
{:gproc, github: "uwiger", tag: "0.8.0"},
|
||||
{:ekka, github: "emqx/ekka", tag: "0.11.1"},
|
||||
# {:gen_rpc, github: "emqx/gen_rpc", tag: "2.5.1"},
|
||||
# {:cuttlefish, github: "emqx/cuttlefish", tag: "v4.0.1"},
|
||||
{:hocon, github: "emqx/hocon", tag: "0.22.0", runtime: false},
|
||||
# {:pbkdf2, github: "emqx/erlang-pbkdf2", tag: "2.0.4"},
|
||||
# {:snabbkaffe, github: "kafka4beam/snabbkaffe", tag: "0.14.0"},
|
||||
# {:jiffy, github: "emqx/jiffy", tag: "1.0.5"},
|
||||
{:lc, github: "qzhuyan/lc", tag: "0.1.2"},
|
||||
]
|
||||
end
|
||||
end
|
|
@ -17,8 +17,8 @@ IsQuicSupp = fun() ->
|
|||
)
|
||||
end,
|
||||
|
||||
Bcrypt = {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {branch, "0.6.0"}}},
|
||||
Quicer = {quicer, {git, "https://github.com/emqx/quic.git", {branch, "0.0.9"}}},
|
||||
Bcrypt = {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.0"}}},
|
||||
Quicer = {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.9"}}},
|
||||
|
||||
ExtraDeps = fun(C) ->
|
||||
{deps, Deps0} = lists:keyfind(deps, 1, C),
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
-include("logger.hrl").
|
||||
-include_lib("lc/include/lc.hrl").
|
||||
|
||||
|
||||
%% gen_event callbacks
|
||||
-export([ init/1
|
||||
, handle_event/2
|
||||
|
|
|
@ -245,6 +245,10 @@ put_raw(KeyPath, Config) -> do_put(?RAW_CONF, KeyPath, Config).
|
|||
%%============================================================================
|
||||
init_load(SchemaMod) ->
|
||||
ConfFiles = application:get_env(emqx, config_files, []),
|
||||
?SLOG(warning, #{ msg => ">>>>>>>>> config:init_load enter"
|
||||
, schema_mod => SchemaMod
|
||||
, conf_files => ConfFiles
|
||||
}),
|
||||
init_load(SchemaMod, ConfFiles).
|
||||
|
||||
%% @doc Initial load of the given config files.
|
||||
|
@ -258,7 +262,9 @@ init_load(SchemaMod, Conf) when is_list(Conf) orelse is_binary(Conf) ->
|
|||
true -> fun hocon:binary/2;
|
||||
false -> fun hocon:files/2
|
||||
end,
|
||||
case Parser(Conf, ParseOptions) of
|
||||
Res = Parser(Conf, ParseOptions),
|
||||
%% io:format(user, "~n>>>>>>>>>>>>>>>>>> config:init_load parse res ~120p ~n", [Res]),
|
||||
case Res of
|
||||
{ok, RawRichConf} ->
|
||||
init_load(SchemaMod, RawRichConf);
|
||||
{error, Reason} ->
|
||||
|
@ -269,6 +275,8 @@ init_load(SchemaMod, Conf) when is_list(Conf) orelse is_binary(Conf) ->
|
|||
error(failed_to_load_hocon_conf)
|
||||
end;
|
||||
init_load(SchemaMod, RawConf) when is_map(RawConf) ->
|
||||
%% io:format(user, ">>>>>>>>>> config:init_load is_map ~p ~100p ~n",
|
||||
%% [SchemaMod, RawConf]),
|
||||
ok = save_schema_mod_and_names(SchemaMod),
|
||||
%% check configs agains the schema, with environment variables applied on top
|
||||
{_AppEnvs, CheckedConf} =
|
||||
|
@ -382,6 +390,8 @@ save_to_app_env(AppEnvs) ->
|
|||
|
||||
-spec save_to_config_map(config(), raw_config()) -> ok.
|
||||
save_to_config_map(Conf, RawConf) ->
|
||||
%% io:format(user, ">>>>>>> config:save_to_config_map ~p ~100p ~n",
|
||||
%% [Conf, RawConf]),
|
||||
?MODULE:put(Conf),
|
||||
?MODULE:put_raw(RawConf).
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
|
@ -0,0 +1,38 @@
|
|||
defmodule EMQXAuthn.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_authn,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Authentication"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [:emqx_authn_sup, :emqx_authn_registry],
|
||||
mod: {:emqx_authn_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false},
|
||||
{:emqx_resource, in_umbrella: true},
|
||||
# {:emqx_http_lib, github: "emqx/emqx_http_lib", tag: "0.2.1"},
|
||||
# {:esasl, github: "emqx/esasl", tag: "0.1.0"},
|
||||
# {:epgsql, github: "epgsql/epgsql", tag: "4.4.0"},
|
||||
# {:mysql, github: "emqx/mysql-otp", tag: "1.7.1"},
|
||||
{:jose, "1.11.2"},
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,38 @@
|
|||
defmodule EMQXAuthn.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_authn,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Authentication"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [:emqx_authn_sup, :emqx_authn_registry],
|
||||
mod: {:emqx_authn_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false},
|
||||
{:emqx_resource, in_umbrella: true},
|
||||
{:emqx_http_lib, github: "emqx/emqx_http_lib", tag: "0.2.1"},
|
||||
{:esasl, github: "emqx/esasl", tag: "0.1.0"},
|
||||
{:epgsql, github: "epgsql/epgsql", tag: "4.4.0"},
|
||||
{:mysql, github: "emqx/mysql-otp", tag: "1.7.1"},
|
||||
{:jose, "1.11.2"}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -1,4 +1,6 @@
|
|||
{deps, []}.
|
||||
{deps, [
|
||||
{jose, "1.11.2"}
|
||||
]}.
|
||||
|
||||
{edoc_opts, [{preprocess, true}]}.
|
||||
{erl_opts, [warn_unused_vars,
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
|
@ -0,0 +1,34 @@
|
|||
defmodule EMQXAuthz.MixProject do
|
||||
use Mix.Project
|
||||
Code.require_file("../../lib/emqx/mix/common.ex")
|
||||
|
||||
@app :emqx_authz
|
||||
|
||||
def project do
|
||||
[
|
||||
app: @app,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps()
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
mod: EMQX.Mix.Common.from_erl!(@app, :mod),
|
||||
applications: EMQX.Mix.Common.from_erl!(@app, :applications),
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx_connector, in_umbrella: true, runtime: false}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
defmodule EMQXAuthz.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_authz,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps()
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx_connector, in_umbrella: true}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
defmodule EMQXAutoSubscribe.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_auto_subscribe,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Auto Subscribe"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [],
|
||||
mod: {:emqx_auto_subscribe_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
defmodule EMQXAutoSubscribe.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_auto_subscribe,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Auto Subscribe"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [],
|
||||
mod: {:emqx_auto_subscribe_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
defmodule EMQXBridge.MixProject do
|
||||
use Mix.Project
|
||||
Code.require_file("../../lib/emqx/mix/common.ex")
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_bridge,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Bridge"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [],
|
||||
mod: {:emqx_bridge_app, []},
|
||||
applications: EMQX.Mix.Common.from_erl!(:emqx_bridge, :applications),
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false},
|
||||
# {:emqx_connector, in_umbrella: true}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,33 @@
|
|||
defmodule EMQXBridge.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_bridge,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Bridge"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [],
|
||||
mod: {:emqx_bridge_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false},
|
||||
{:emqx_connector, in_umbrella: true}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
defmodule EMQXConf.MixProject do
|
||||
use Mix.Project
|
||||
Code.require_file("../../lib/emqx/mix/common.ex")
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_conf,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Configuration Management"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
mod: {:emqx_conf_app, []},
|
||||
# applications: EMQX.Mix.Common.erl_apps(:emqx_conf),
|
||||
# included_applications: [:hocon],
|
||||
# extra_applications: [:logger, :os_mon, :syntax_tools]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false},
|
||||
{:hocon, github: "emqx/hocon", tag: "0.22.0"},
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
defmodule EMQXConf.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_conf,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Configuration Management"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
mod: {:emqx_conf_app, []},
|
||||
extra_applications: [:logger, :os_mon, :syntax_tools]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false},
|
||||
{:hocon, github: "emqx/hocon"}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -25,7 +25,11 @@
|
|||
-include("emqx_conf.hrl").
|
||||
|
||||
start(_StartType, _StartArgs) ->
|
||||
?SLOG(warning, #{ msg => ">>>>>>>>>>>>>> emqx_conf_app starting <<<<<<<<<<<~n"
|
||||
}),
|
||||
init_conf(),
|
||||
?SLOG(warning, #{ msg => ">>>>>>>>>>>>>> emqx_conf_app conf init done <<<<<<<<<<<~n"
|
||||
}),
|
||||
emqx_conf_sup:start_link().
|
||||
|
||||
stop(_State) ->
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
|
@ -0,0 +1,39 @@
|
|||
defmodule EMQXConnector.MixProject do
|
||||
use Mix.Project
|
||||
Code.require_file("../../lib/emqx/mix/common.ex")
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_connector,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps()
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
mod: {:emqx_connector_app, []},
|
||||
applications: EMQX.Mix.Common.from_erl!(:emqx_connector, :applications),
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx_resource, in_umbrella: true, runtime: false},
|
||||
{:epgsql, github: "epgsql/epgsql", tag: "4.4.0"},
|
||||
{:mysql, github: "emqx/mysql-otp", tag: "1.7.1"},
|
||||
{:emqtt, github: "emqx/emqtt", tag: "1.4.3"},
|
||||
{:eredis_cluster, github: "emqx/eredis_cluster", tag: "0.6.7"},
|
||||
{:mongodb, github: "emqx/mongodb-erlang", tag: "v3.0.10"},
|
||||
# {:ecpool, github: "emqx/ecpool", tag: "0.5.1"},
|
||||
# {:emqtt, github: "emqx/emqtt", tag: "1.4.3"}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,33 @@
|
|||
defmodule EMQXConnector.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_connector,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps()
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
mod: {:emqx_connector_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx_resource, in_umbrella: true},
|
||||
{:mysql, github: "emqx/mysql-otp", tag: "1.7.1"},
|
||||
{:ecpool, github: "emqx/ecpool", tag: "0.5.1"},
|
||||
{:emqtt, github: "emqx/emqtt", tag: "1.4.3"}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
|
@ -0,0 +1,35 @@
|
|||
defmodule EMQXDashboard.MixProject do
|
||||
use Mix.Project
|
||||
Code.require_file("../../lib/emqx/mix/common.ex")
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_dashboard,
|
||||
version: "4.4.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Web Dashboard"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [:emqx_dashboard_sup],
|
||||
mod: {:emqx_dashboard_app, []},
|
||||
applications: EMQX.Mix.Common.from_erl!(:emqx_dashboard, :applications),
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false},
|
||||
# {:minirest, github: "emqx/minirest", tag: "1.2.4"}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,33 @@
|
|||
defmodule EMQXDashboard.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_dashboard,
|
||||
version: "4.4.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Web Dashboard"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [:emqx_dashboard_sup],
|
||||
mod: {:emqx_dashboard_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false},
|
||||
{:minirest, github: "emqx/minirest", tag: "1.2.4"}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -212,13 +212,17 @@ sha256(SaltBin, Password) ->
|
|||
crypto:hash('sha256', <<SaltBin/binary, Password/binary>>).
|
||||
|
||||
add_default_user() ->
|
||||
io:format(user, "~n>>>>>>>>>>> add_default_user/0~n", []),
|
||||
add_default_user(binenv(default_username), binenv(default_password)).
|
||||
|
||||
binenv(Key) ->
|
||||
iolist_to_binary(emqx_conf:get([emqx_dashboard, Key], "")).
|
||||
|
||||
add_default_user(Username, Password) when ?EMPTY_KEY(Username) orelse ?EMPTY_KEY(Password) ->
|
||||
ok;
|
||||
%% FIXME!!!
|
||||
io:format(user, "~n>>>>>>>>>>> add_default_user empty ~n", []),
|
||||
{ok, empty};
|
||||
%% ok;
|
||||
|
||||
add_default_user(Username, Password) ->
|
||||
case lookup_user(Username) of
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
defmodule EMQXExhook.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_exhook,
|
||||
version: "5.0.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
compilers: [:protos | Mix.compilers()],
|
||||
aliases: ["compile.protos": &protos/1],
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Extension for Hook"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [],
|
||||
mod: {:emqx_exhook_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true},
|
||||
{:grpc, github: "emqx/grpc-erl", tag: "0.6.2"},
|
||||
]
|
||||
end
|
||||
|
||||
defp protos(_args) do
|
||||
app_path = Path.expand("..", __ENV__.file)
|
||||
config = [
|
||||
:use_packages,
|
||||
:maps,
|
||||
:strings_as_binaries,
|
||||
rename: {:msg_name, :snake_case},
|
||||
rename: {:msg_fqname, :base_name},
|
||||
i: '.',
|
||||
report_errors: false,
|
||||
o: app_path |> Path.join("src") |> to_charlist(),
|
||||
module_name_prefix: 'emqx_',
|
||||
module_name_suffix: '_pb'
|
||||
]
|
||||
|
||||
app_path
|
||||
|> Path.join("priv/protos/*.proto")
|
||||
|> Path.wildcard()
|
||||
|> Enum.map(&to_charlist/1)
|
||||
|> Enum.each(&:gpb_compile.file(&1, config))
|
||||
|
||||
:ok
|
||||
end
|
||||
end
|
|
@ -0,0 +1,59 @@
|
|||
defmodule EMQXExhook.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_exhook,
|
||||
version: "5.0.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
compilers: [:protos | Mix.compilers()],
|
||||
aliases: ["compile.protos": &protos/1],
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Extension for Hook"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [],
|
||||
mod: {:emqx_exhook_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false},
|
||||
{:grpc, github: "emqx/grpc-erl", tag: "0.6.2"}
|
||||
]
|
||||
end
|
||||
|
||||
defp protos(_args) do
|
||||
app_path = Path.expand("..", __ENV__.file)
|
||||
config = [
|
||||
:use_packages,
|
||||
:maps,
|
||||
:strings_as_binaries,
|
||||
rename: {:msg_name, :snake_case},
|
||||
rename: {:msg_fqname, :base_name},
|
||||
i: '.',
|
||||
report_errors: false,
|
||||
o: app_path |> Path.join("src") |> to_charlist(),
|
||||
module_name_prefix: 'emqx_',
|
||||
module_name_suffix: '_pb'
|
||||
]
|
||||
|
||||
app_path
|
||||
|> Path.join("priv/protos/*.proto")
|
||||
|> Path.wildcard()
|
||||
|> Enum.map(&to_charlist/1)
|
||||
|> Enum.each(&:gpb_compile.file(&1, config))
|
||||
|
||||
:ok
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
|
@ -0,0 +1,64 @@
|
|||
defmodule EMQXGateway.MixProject do
|
||||
use Mix.Project
|
||||
Code.require_file("../../lib/emqx/mix/common.ex")
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_gateway,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
compilers: [:protos | Mix.compilers()],
|
||||
aliases: ["compile.protos": &protos/1],
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "The Gateway Management Application"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [],
|
||||
mod: {:emqx_gateway_app, []},
|
||||
applications: EMQX.Mix.Common.from_erl!(:emqx_gateway, :applications),
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp protos(_args) do
|
||||
app_path = Path.expand("..", __ENV__.file)
|
||||
config = [
|
||||
:use_packages,
|
||||
:maps,
|
||||
:strings_as_binaries,
|
||||
rename: {:msg_name, :snake_case},
|
||||
rename: {:msg_fqname, :base_name},
|
||||
i: '.',
|
||||
report_errors: false,
|
||||
o: app_path |> Path.join("src/exproto") |> to_charlist(),
|
||||
module_name_prefix: 'emqx_',
|
||||
module_name_suffix: '_pb'
|
||||
]
|
||||
|
||||
app_path
|
||||
|> Path.join("src/exproto/protos/*.proto")
|
||||
|> Path.wildcard()
|
||||
|> Enum.map(&to_charlist/1)
|
||||
|> Enum.each(&:gpb_compile.file(&1, config))
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
# {:gpb, "4.19.1", runtime: false},
|
||||
{:emqx, in_umbrella: true, runtime: false},
|
||||
{:grpc, github: "emqx/grpc-erl", tag: "0.6.2"},
|
||||
# {:lwm2m_coap, github: "emqx/lwm2m-coap", tag: "v2.0.0"},
|
||||
# {:esockd, github: "emqx/esockd", tag: "5.7.4"}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,62 @@
|
|||
defmodule EMQXGateway.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_gateway,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
compilers: [:protos | Mix.compilers()],
|
||||
aliases: ["compile.protos": &protos/1],
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "The Gateway Management Application"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [],
|
||||
mod: {:emqx_gateway_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp protos(_args) do
|
||||
app_path = Path.expand("..", __ENV__.file)
|
||||
config = [
|
||||
:use_packages,
|
||||
:maps,
|
||||
:strings_as_binaries,
|
||||
rename: {:msg_name, :snake_case},
|
||||
rename: {:msg_fqname, :base_name},
|
||||
i: '.',
|
||||
report_errors: false,
|
||||
o: app_path |> Path.join("src/exproto") |> to_charlist(),
|
||||
module_name_prefix: 'emqx_',
|
||||
module_name_suffix: '_pb'
|
||||
]
|
||||
|
||||
app_path
|
||||
|> Path.join("src/exproto/protos/*.proto")
|
||||
|> Path.wildcard()
|
||||
|> Enum.map(&to_charlist/1)
|
||||
|> Enum.each(&:gpb_compile.file(&1, config))
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:gpb, "4.19.1", runtime: false},
|
||||
{:emqx, in_umbrella: true},
|
||||
{:lwm2m_coap, github: "emqx/lwm2m-coap", tag: "v2.0.0"},
|
||||
{:grpc, github: "emqx/grpc-erl", tag: "0.6.2"},
|
||||
{:esockd, github: "emqx/esockd", tag: "5.7.4"}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
-behaviour(minirest_api).
|
||||
|
||||
-include_lib("emqx_gateway/src/coap/include/emqx_coap.hrl").
|
||||
-include("emqx_coap.hrl").
|
||||
|
||||
%% API
|
||||
-export([api_spec/0]).
|
||||
|
|
|
@ -41,8 +41,9 @@
|
|||
|
||||
-export_type([channel/0]).
|
||||
|
||||
-include("emqx_coap.hrl").
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
-include_lib("emqx_gateway/src/coap/include/emqx_coap.hrl").
|
||||
%% -include_lib("emqx_gateway/src/coap/include/emqx_coap.hrl").
|
||||
-include_lib("emqx/include/emqx_authentication.hrl").
|
||||
|
||||
-define(AUTHN, ?EMQX_AUTHENTICATION_CONFIG_ROOT_NAME_ATOM).
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
%% API
|
||||
-export([]).
|
||||
|
||||
-include("include/emqx_coap.hrl").
|
||||
-include("apps/emqx/include/types.hrl").
|
||||
-include_lib("emqx/include/types.hrl").
|
||||
-include("emqx_coap.hrl").
|
||||
|
||||
-define(VERSION, 1).
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
-module(emqx_coap_medium).
|
||||
|
||||
-include_lib("emqx_gateway/src/coap/include/emqx_coap.hrl").
|
||||
-include("emqx_coap.hrl").
|
||||
|
||||
%% API
|
||||
-export([ empty/0, reset/1, reset/2
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
-export([ set/3, set_payload/2, get_option/2
|
||||
, get_option/3, set_payload_block/3, set_payload_block/4]).
|
||||
|
||||
-include_lib("emqx_gateway/src/coap/include/emqx_coap.hrl").
|
||||
-include("emqx_coap.hrl").
|
||||
|
||||
request(Type, Method) ->
|
||||
request(Type, Method, <<>>, []).
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
-include_lib("emqx/include/emqx.hrl").
|
||||
-include_lib("emqx/include/emqx_mqtt.hrl").
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
-include_lib("emqx_gateway/src/coap/include/emqx_coap.hrl").
|
||||
-include("emqx_coap.hrl").
|
||||
|
||||
%% API
|
||||
-export([ new/0
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
-export_type([manager/0, event_result/1]).
|
||||
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
-include_lib("emqx_gateway/src/coap/include/emqx_coap.hrl").
|
||||
-include("emqx_coap.hrl").
|
||||
|
||||
-type direction() :: in | out.
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
-module(emqx_coap_transport).
|
||||
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
-include_lib("emqx_gateway/src/coap/include/emqx_coap.hrl").
|
||||
-include("emqx_coap.hrl").
|
||||
|
||||
-define(ACK_TIMEOUT, 2000).
|
||||
-define(ACK_RANDOM_FACTOR, 1000).
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
-module(emqx_coap_mqtt_handler).
|
||||
|
||||
-include_lib("emqx_gateway/src/coap/include/emqx_coap.hrl").
|
||||
-include("emqx_coap.hrl").
|
||||
|
||||
-export([handle_request/4]).
|
||||
-import(emqx_coap_message, [response/2, response/3]).
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
-module(emqx_coap_pubsub_handler).
|
||||
|
||||
-include_lib("emqx/include/emqx_mqtt.hrl").
|
||||
-include_lib("emqx_gateway/src/coap/include/emqx_coap.hrl").
|
||||
-include("emqx_coap.hrl").
|
||||
|
||||
-export([handle_request/4]).
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
%%--------------------------------------------------------------------
|
||||
|
||||
-module(emqx_exproto_channel).
|
||||
-include("src/exproto/include/emqx_exproto.hrl").
|
||||
-include("emqx_exproto.hrl").
|
||||
-include_lib("emqx/include/emqx.hrl").
|
||||
-include_lib("emqx/include/emqx_mqtt.hrl").
|
||||
-include_lib("emqx/include/types.hrl").
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
% -behaviour(emqx_exproto_v_1_connection_adapter_bhvr).
|
||||
|
||||
-include("src/exproto/include/emqx_exproto.hrl").
|
||||
-include("emqx_exproto.hrl").
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
|
||||
-define(IS_QOS(X), (X =:= 0 orelse X =:= 1 orelse X =:= 2)).
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
-module(emqx_lwm2m_channel).
|
||||
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
-include_lib("emqx_gateway/src/coap/include/emqx_coap.hrl").
|
||||
-include_lib("emqx_gateway/src/lwm2m/include/emqx_lwm2m.hrl").
|
||||
-include("emqx_coap.hrl").
|
||||
-include("emqx_lwm2m.hrl").
|
||||
|
||||
%% API
|
||||
-export([ info/1
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
-module(emqx_lwm2m_cmd).
|
||||
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
-include_lib("emqx_gateway/src/coap/include/emqx_coap.hrl").
|
||||
-include_lib("emqx_gateway/src/lwm2m/include/emqx_lwm2m.hrl").
|
||||
-include("emqx_coap.hrl").
|
||||
-include("emqx_lwm2m.hrl").
|
||||
|
||||
-export([ mqtt_to_coap/2
|
||||
, coap_to_mqtt/4
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
, translate_json/1
|
||||
]).
|
||||
|
||||
-include("src/lwm2m/include/emqx_lwm2m.hrl").
|
||||
-include("emqx_lwm2m.hrl").
|
||||
|
||||
tlv_to_json(BaseName, TlvData) ->
|
||||
DecodedTlv = emqx_lwm2m_tlv:parse(TlvData),
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
-include_lib("emqx/include/logger.hrl").
|
||||
-include_lib("emqx/include/emqx.hrl").
|
||||
-include_lib("emqx/include/emqx_mqtt.hrl").
|
||||
-include_lib("emqx_gateway/src/coap/include/emqx_coap.hrl").
|
||||
-include_lib("emqx_gateway/src/lwm2m/include/emqx_lwm2m.hrl").
|
||||
-include("emqx_coap.hrl").
|
||||
-include("emqx_lwm2m.hrl").
|
||||
|
||||
%% API
|
||||
-export([ new/0, init/4, update/3, parse_object_list/1
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
-export([binary_to_hex_string/1]).
|
||||
-endif.
|
||||
|
||||
-include("src/lwm2m/include/emqx_lwm2m.hrl").
|
||||
-include("emqx_lwm2m.hrl").
|
||||
|
||||
-define(TLV_TYPE_OBJECT_INSTANCE, 0).
|
||||
-define(TLV_TYPE_RESOURCE_INSTANCE, 1).
|
||||
|
@ -158,4 +158,3 @@ encode_value(Value) ->
|
|||
binary_to_hex_string(Data) ->
|
||||
lists:flatten([io_lib:format("~2.16.0B ",[X]) || <<X:8>> <= Data ]).
|
||||
-endif.
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
-module(emqx_lwm2m_xml_object).
|
||||
|
||||
-include_lib("emqx_gateway/src/lwm2m/include/emqx_lwm2m.hrl").
|
||||
-include_lib("xmerl/include/xmerl.hrl").
|
||||
-include("emqx_lwm2m.hrl").
|
||||
|
||||
-export([ get_obj_def/2
|
||||
, get_object_id/1
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
-module(emqx_lwm2m_xml_object_db).
|
||||
|
||||
-include_lib("emqx_gateway/src/lwm2m/include/emqx_lwm2m.hrl").
|
||||
-include_lib("xmerl/include/xmerl.hrl").
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
-include("emqx_lwm2m.hrl").
|
||||
|
||||
% This module is for future use. Disabled now.
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
-behaviour(gen_server).
|
||||
|
||||
-include("src/mqttsn/include/emqx_sn.hrl").
|
||||
-include("emqx_sn.hrl").
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
|
||||
-export([ start_link/2
|
||||
|
@ -106,4 +106,3 @@ send_advertise(#state{gwid = GwId, sock = Sock, port = Port,
|
|||
boradcast_addrs() ->
|
||||
lists:usort([Addr || {ok, IfList} <- [inet:getiflist()], If <- IfList,
|
||||
{ok, [{broadaddr, Addr}]} <- [inet:ifget(If, [broadaddr])]]).
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
-behaviour(emqx_gateway_channel).
|
||||
|
||||
-include("src/mqttsn/include/emqx_sn.hrl").
|
||||
-include("emqx_sn.hrl").
|
||||
-include_lib("emqx/include/emqx.hrl").
|
||||
-include_lib("emqx/include/emqx_mqtt.hrl").
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
-behaviour(emqx_gateway_frame).
|
||||
|
||||
-include("src/mqttsn/include/emqx_sn.hrl").
|
||||
-include("emqx_sn.hrl").
|
||||
|
||||
-export([ initial_parse_state/1
|
||||
, serialize_opts/0
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
-behaviour(gen_server).
|
||||
|
||||
-include("src/mqttsn/include/emqx_sn.hrl").
|
||||
-include("emqx_sn.hrl").
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
|
||||
-export([ start_link/2
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
-behaviour(emqx_gateway_channel).
|
||||
|
||||
-include("src/stomp/include/emqx_stomp.hrl").
|
||||
-include("emqx_stomp.hrl").
|
||||
-include_lib("emqx/include/emqx.hrl").
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
|
||||
-behaviour(emqx_gateway_frame).
|
||||
|
||||
-include("src/stomp/include/emqx_stomp.hrl").
|
||||
-include("emqx_stomp.hrl").
|
||||
|
||||
-export([ initial_parse_state/1
|
||||
, parse/2
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
%% @doc Stomp heartbeat.
|
||||
-module(emqx_stomp_heartbeat).
|
||||
|
||||
-include("src/stomp/include/emqx_stomp.hrl").
|
||||
-include("emqx_stomp.hrl").
|
||||
|
||||
-export([ init/1
|
||||
, check/3
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
defmodule EMQXLimiter.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_limiter,
|
||||
version: "1.0.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Hierachical Limiter"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [:emqx_limiter_sup],
|
||||
mod: {:emqx_limiter_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false},
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
defmodule EMQXLimiter.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_limiter,
|
||||
version: "1.0.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Hierachical Limiter"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [:emqx_limiter_sup],
|
||||
mod: {:emqx_limiter_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,30 @@
|
|||
defmodule EMQXMachine.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_machine,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "The EMQ X Machine"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [],
|
||||
mod: {:emqx_machine_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,30 @@
|
|||
defmodule EMQXMachine.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_machine,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "The EMQ X Machine"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [],
|
||||
mod: {:emqx_machine_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[]
|
||||
end
|
||||
end
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
%% @doc EMQ X boot entrypoint.
|
||||
start() ->
|
||||
?SLOG(warning, #{ msg => ">>>>>>>>> machine:start enter"
|
||||
}),
|
||||
case os:type() of
|
||||
{win32, nt} -> ok;
|
||||
_nix ->
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
-endif.
|
||||
|
||||
post_boot() ->
|
||||
%% io:format(user, ">>>>>>>>>>>>>>>>>>>> roots ~p~n",
|
||||
%% [emqx_conf_schema:roots()]),
|
||||
ok = ensure_apps_started(),
|
||||
_ = emqx_plugins:load(),
|
||||
ok = print_vsn(),
|
||||
|
@ -108,18 +110,49 @@ reboot_apps() ->
|
|||
|
||||
sorted_reboot_apps() ->
|
||||
Apps = [{App, app_deps(App)} || App <- reboot_apps()],
|
||||
sorted_reboot_apps(Apps).
|
||||
?SLOG(warning, #{ msg => "sorted_reboot_apps/0 before /1"
|
||||
, apps => Apps
|
||||
}),
|
||||
Res = sorted_reboot_apps(Apps),
|
||||
io:format(user, "~n>>>>>>>>>>>>>> sorted_reboot_apps~n ~100p~n", [Res]),
|
||||
Res,
|
||||
%% FIXME!!!!! For some reason, emqx_conf appears in the
|
||||
%% `applications` key in resource, but it is not there in the
|
||||
%% .app.src...
|
||||
Res0 = [emqx_conf,gproc,esockd,ranch,cowboy,emqx,emqx_prometheus,emqx_modules,emqx_dashboard,
|
||||
emqx_gateway,emqx_management,emqx_retainer,emqx_statsd,emqx_resource,emqx_connector,emqx_bridge,
|
||||
emqx_authn,emqx_authz,emqx_exhook],
|
||||
case true of
|
||||
true ->
|
||||
Res;
|
||||
false ->
|
||||
Res0
|
||||
end.
|
||||
|
||||
app_deps(App) ->
|
||||
case application:get_key(App, applications) of
|
||||
undefined -> [];
|
||||
{ok, List} -> lists:filter(fun(A) -> lists:member(A, reboot_apps()) end, List)
|
||||
{ok, List} ->
|
||||
?SLOG(warning, #{ msg => ">>>>>> machine_boot:add_deps"
|
||||
, app => App
|
||||
, apps => List
|
||||
, included => application:get_key(App, included_applications)
|
||||
}),
|
||||
lists:filter(fun(A) ->
|
||||
lists:member(A, reboot_apps())
|
||||
end, List)
|
||||
end.
|
||||
|
||||
sorted_reboot_apps(Apps) ->
|
||||
G = digraph:new(),
|
||||
try
|
||||
lists:foreach(fun({App, Deps}) -> add_app(G, App, Deps) end, Apps),
|
||||
lists:foreach(fun({App, Deps}) ->
|
||||
?SLOG(warning, #{ msg => ">>>>>> machine_boot:add_app"
|
||||
, app => App
|
||||
, deps => Deps
|
||||
}),
|
||||
add_app(G, App, Deps)
|
||||
end, Apps),
|
||||
case digraph_utils:topsort(G) of
|
||||
Sorted when is_list(Sorted) ->
|
||||
Sorted;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
|
@ -0,0 +1,38 @@
|
|||
defmodule EMQXManagement.MixProject do
|
||||
use Mix.Project
|
||||
Code.require_file("../../lib/emqx/mix/common.ex")
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_management,
|
||||
version: "4.4.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Management API and CLI"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [:emqx_management_sup],
|
||||
mod: {:emqx_mgmt_app, []},
|
||||
applications: EMQX.Mix.Common.from_erl!(:emqx_management, :applications),
|
||||
extra_applications: [:logger, :syntax_tools]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false},
|
||||
# {:emqx_rule_engine, in_umbrella: true},
|
||||
# {:ekka, github: "emqx/ekka", tag: "0.11.1", runtime: false},
|
||||
# {:emqx_http_lib, github: "emqx/emqx_http_lib", tag: "0.2.1"},
|
||||
{:minirest, github: "emqx/minirest", tag: "1.2.7"},
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
defmodule EMQXManagement.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_management,
|
||||
version: "4.4.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Management API and CLI"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [:emqx_management_sup],
|
||||
mod: {:emqx_mgmt_app, []},
|
||||
extra_applications: [:logger, :syntax_tools]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx_rule_engine, in_umbrella: true},
|
||||
{:ekka, github: "emqx/ekka", tag: "0.11.1", runtime: false},
|
||||
{:emqx_http_lib, github: "emqx/emqx_http_lib", tag: "0.2.1"},
|
||||
{:minirest, github: "emqx/minirest", tag: "1.2.4"}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
|
@ -0,0 +1,33 @@
|
|||
defmodule EMQXModules.MixProject do
|
||||
use Mix.Project
|
||||
Code.require_file("../../lib/emqx/mix/common.ex")
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_modules,
|
||||
version: "4.3.2",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps()
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [:emqx_mod_sup],
|
||||
mod: {:emqx_modules_app, []},
|
||||
applications: EMQX.Mix.Common.from_erl!(:emqx_modules, :applications),
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false},
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
defmodule EMQXModules.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_modules,
|
||||
version: "4.3.2",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps()
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [:emqx_mod_sup],
|
||||
mod: {:emqx_modules_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[]
|
||||
end
|
||||
end
|
|
@ -24,6 +24,18 @@
|
|||
|
||||
start(_Type, _Args) ->
|
||||
{ok, Sup} = emqx_modules_sup:start_link(),
|
||||
%% io:format(user, "~n>>>>>>>>>>>> modules_app:start sup children ~p~n",
|
||||
%% [supervisor:which_children(Sup)]),
|
||||
%% io:format(user, "~n>>>>>>>>>>>> modules_app:start get_release ~p~n",
|
||||
%% [emqx_app:get_release()]),
|
||||
%% io:format(user, "~n>>>>>>>>>>>> modules_app:start official_version ~p~n",
|
||||
%% [emqx_telemetry:official_version(emqx_app:get_release())]),
|
||||
%% io:format(user, "~n>>>>>>>>>>>> modules_app:start config files ~p~n",
|
||||
%% [application:get_env(emqx, config_files, [])]),
|
||||
%% io:format(user, "~n>>>>>>>>>>>> modules_app:start retainer config ~p~n",
|
||||
%% [emqx:get_config([emqx_retainer], undefined)]),
|
||||
%% io:format(user, "~n>>>>>>>>>>>> modules_app:start authz_api_settings:api_spec ~p~n",
|
||||
%% [emqx_authz_api_settings:api_spec()]),
|
||||
maybe_enable_modules(),
|
||||
{ok, Sup}.
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
|
@ -0,0 +1,28 @@
|
|||
defmodule EMQXPluginLibs.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_plugin_libs,
|
||||
version: "4.3.1",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Plugin utility libs"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,28 @@
|
|||
defmodule EMQXPluginLibs.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_plugin_libs,
|
||||
version: "4.3.1",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X Plugin utility libs"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
|
@ -0,0 +1,33 @@
|
|||
defmodule EMQXPrometheus.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_prometheus,
|
||||
version: "4.3.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "Prometheus for EMQ X"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [:emqx_prometheus_sup],
|
||||
mod: {:emqx_prometheus_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true},
|
||||
{:prometheus, github: "emqx/prometheus.erl", tag: "v3.1.1"}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
defmodule EMQXPrometheus.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_prometheus,
|
||||
version: "4.3.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "Prometheus for EMQ X"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [:emqx_prometheus_sup],
|
||||
mod: {:emqx_prometheus_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:prometheus, github: "emqx/prometheus.erl", tag: "v3.1.1"}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
defmodule EmqxPSK.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_psk,
|
||||
version: "5.0.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
# start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X PSK"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [:emqx_psk_sup],
|
||||
mod: {:emqx_psk_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
defmodule EmqxPSK.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_psk,
|
||||
version: "5.0.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
description: "EMQ X PSK"
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
registered: [:emqx_psk_sup],
|
||||
mod: {:emqx_psk_app, []},
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:emqx, in_umbrella: true, runtime: false}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
|
||||
locals_without_parens: [
|
||||
start_type: 1,
|
||||
overlay: 1,
|
||||
mkdir: 1,
|
||||
copy: 2,
|
||||
template: 2
|
||||
]
|
||||
]
|
|
@ -0,0 +1,26 @@
|
|||
# The directory Mix will write compiled artifacts to.
|
||||
/_build/
|
||||
|
||||
# If you run "mix test --cover", coverage assets end up here.
|
||||
/cover/
|
||||
|
||||
# The directory Mix downloads your dependencies sources to.
|
||||
/deps/
|
||||
|
||||
# Where third-party dependencies like ExDoc output generated docs.
|
||||
/doc/
|
||||
|
||||
# Ignore .fetch files in case you like to edit your project deps locally.
|
||||
/.fetch
|
||||
|
||||
# If the VM crashes, it generates a dump, let's ignore it too.
|
||||
erl_crash.dump
|
||||
|
||||
# Also ignore archive artifacts (built via "mix archive.build").
|
||||
*.ez
|
||||
|
||||
# Ignore package tarball (built via "mix hex.build").
|
||||
emqx_release_helper-*.tar
|
||||
|
||||
# Temporary files, for example, from tests.
|
||||
/tmp/
|
|
@ -0,0 +1,21 @@
|
|||
# EmqxReleaseHelper
|
||||
|
||||
**TODO: Add description**
|
||||
|
||||
## Installation
|
||||
|
||||
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
|
||||
by adding `emqx_release_helper` to your list of dependencies in `mix.exs`:
|
||||
|
||||
```elixir
|
||||
def deps do
|
||||
[
|
||||
{:emqx_release_helper, "~> 0.1.0"}
|
||||
]
|
||||
end
|
||||
```
|
||||
|
||||
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
|
||||
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
|
||||
be found at [https://hexdocs.pm/emqx_release_helper](https://hexdocs.pm/emqx_release_helper).
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
defmodule EmqxReleaseHelper do
|
||||
def applications do
|
||||
config = profile_vars()
|
||||
|
||||
EmqxReleaseHelper.Applications.__all__()
|
||||
|> Enum.filter(fn
|
||||
%{enable?: fun} -> fun.(config)
|
||||
_ -> true
|
||||
end)
|
||||
|> Enum.map(fn %{name: name, start_type: start_type} -> {name, start_type} end)
|
||||
end
|
||||
|
||||
def run(release) do
|
||||
config = Map.merge(profile_vars(), release_vars(release))
|
||||
|
||||
release
|
||||
|> EmqxReleaseHelper.Script.run(config)
|
||||
|> EmqxReleaseHelper.Overlay.run(config)
|
||||
|> EmqxReleaseHelper.Applications.run(config)
|
||||
end
|
||||
|
||||
def profile_vars() do
|
||||
"RELEASE_PROFILE"
|
||||
|> System.get_env("emqx")
|
||||
|> String.to_existing_atom()
|
||||
|> case do
|
||||
:emqx ->
|
||||
%{
|
||||
release_type: :cloud,
|
||||
package_type: :bin
|
||||
}
|
||||
end
|
||||
|> Map.merge(%{
|
||||
erts_vsn: :version |> :erlang.system_info() |> to_string(),
|
||||
project_path: EMQXUmbrella.MixProject.project_path(),
|
||||
enable_bcrypt: EMQXUmbrella.MixProject.enable_bcrypt(),
|
||||
enable_plugin_emqx_modules: false,
|
||||
enable_plugin_emqx_retainer: true,
|
||||
apps_paths: Mix.Project.apps_paths(),
|
||||
built_on_arch: get_arch()
|
||||
})
|
||||
|> then(fn %{release_type: release_type} = config ->
|
||||
Map.merge(config, profile_vars(:release_type, release_type))
|
||||
end)
|
||||
|> then(fn %{package_type: package_type} = config ->
|
||||
Map.merge(config, profile_vars(:package_type, package_type))
|
||||
end)
|
||||
end
|
||||
|
||||
defp profile_vars(:release_type, :cloud) do
|
||||
%{
|
||||
emqx_description: "EMQ X Broker",
|
||||
enable_plugin_emqx_rule_engine: true,
|
||||
enable_plugin_emqx_bridge_mqtt: false
|
||||
}
|
||||
end
|
||||
|
||||
defp profile_vars(:release_type, :edge) do
|
||||
%{
|
||||
emqx_description: "EMQ X Edge",
|
||||
enable_plugin_emqx_rule_engine: false,
|
||||
enable_plugin_emqx_bridge_mqtt: true
|
||||
}
|
||||
end
|
||||
|
||||
defp profile_vars(:package_type, :bin) do
|
||||
%{
|
||||
platform_bin_dir: "bin",
|
||||
platform_data_dir: "data",
|
||||
platform_etc_dir: "etc",
|
||||
platform_lib_dir: "lib",
|
||||
platform_log_dir: "log",
|
||||
platform_plugins_dir: "etc/plugins",
|
||||
runner_root_dir: "$(cd $(dirname $(readlink $0 || echo $0))/..; pwd -P)",
|
||||
runner_bin_dir: "$RUNNER_ROOT_DIR/bin",
|
||||
runner_etc_dir: "$RUNNER_ROOT_DIR/etc",
|
||||
runner_lib_dir: "$RUNNER_ROOT_DIR/lib",
|
||||
runner_log_dir: "$RUNNER_ROOT_DIR/log",
|
||||
runner_data_dir: "$RUNNER_ROOT_DIR/data",
|
||||
runner_user: ""
|
||||
}
|
||||
end
|
||||
|
||||
defp profile_vars(:package_type, :pkg) do
|
||||
%{
|
||||
platform_bin_dir: "",
|
||||
platform_data_dir: "/var/lib/emqx",
|
||||
platform_etc_dir: "/etc/emqx",
|
||||
platform_lib_dir: "",
|
||||
platform_log_dir: "/var/log/emqx",
|
||||
platform_plugins_dir: "/var/lib/emqx/plugins",
|
||||
runner_root_dir: "/usr/lib/emqx",
|
||||
runner_bin_dir: "/usr/bin",
|
||||
runner_etc_dir: "/etc/emqx",
|
||||
runner_lib_dir: "$RUNNER_ROOT_DIR/lib",
|
||||
runner_log_dir: "/var/log/emqx",
|
||||
runner_data_dir: "/var/lib/emqx",
|
||||
runner_user: "emqx"
|
||||
}
|
||||
end
|
||||
|
||||
defp release_vars(release) do
|
||||
%{
|
||||
release_version: release.version,
|
||||
release_path: release.path,
|
||||
release_version_path: release.version_path
|
||||
}
|
||||
end
|
||||
|
||||
defp get_arch do
|
||||
major_version = System.otp_release()
|
||||
|
||||
otp_release =
|
||||
[:code.root_dir(), "releases", major_version, "OTP_VERSION"]
|
||||
|> Path.join()
|
||||
|> File.read()
|
||||
|> case do
|
||||
{:ok, version} -> String.trim(version)
|
||||
{:error, _} -> major_version
|
||||
end
|
||||
|
||||
wordsize =
|
||||
try do
|
||||
:erlang.system_info({:wordsize, :external}) * 8
|
||||
rescue
|
||||
_ ->
|
||||
:erlang.system_info(:wordsize) * 8
|
||||
end
|
||||
|
||||
Enum.join([otp_release, :erlang.system_info(:system_architecture), wordsize], "-")
|
||||
end
|
||||
end
|
|
@ -0,0 +1,138 @@
|
|||
defmodule EmqxReleaseHelper.Applications do
|
||||
use EmqxReleaseHelper.DSL.Application
|
||||
|
||||
application :emqx do
|
||||
start_type :load
|
||||
|
||||
overlay %{release_type: release_type} do
|
||||
copy "etc/certs", "etc/certs"
|
||||
|
||||
template "etc/ssl_dist.conf", "etc/ssl_dist.conf"
|
||||
template "etc/emqx_#{release_type}/vm.args", "etc/vm.args"
|
||||
end
|
||||
end
|
||||
|
||||
application :emqx_conf do
|
||||
start_type :load
|
||||
|
||||
overlay do
|
||||
template "etc/emqx.conf.all", "etc/emqx.conf"
|
||||
end
|
||||
end
|
||||
|
||||
application :lc do
|
||||
start_type :load
|
||||
end
|
||||
|
||||
application :esasl do
|
||||
start_type :load
|
||||
end
|
||||
|
||||
application :mria do
|
||||
start_type :load
|
||||
end
|
||||
|
||||
application :mnesia do
|
||||
start_type :load
|
||||
end
|
||||
|
||||
application :ekka do
|
||||
start_type :load
|
||||
end
|
||||
|
||||
application :emqx_plugin_libs do
|
||||
start_type :load
|
||||
end
|
||||
|
||||
application :emqx_gateway do
|
||||
start_type :load
|
||||
|
||||
overlay do
|
||||
copy "src/lwm2m/lwm2m_xml", "etc/lwm2m_xml"
|
||||
end
|
||||
end
|
||||
|
||||
application :emqx_resource do
|
||||
start_type :load
|
||||
end
|
||||
|
||||
application :emqx_connector do
|
||||
start_type :load
|
||||
end
|
||||
|
||||
application :emqx_bridge do
|
||||
start_type :load
|
||||
end
|
||||
|
||||
application :emqx_authn do
|
||||
start_type :load
|
||||
end
|
||||
|
||||
application :emqx_authz do
|
||||
start_type :load
|
||||
|
||||
overlay do
|
||||
template "etc/acl.conf", "etc/acl.conf"
|
||||
end
|
||||
end
|
||||
|
||||
application :emqx_machine do
|
||||
start_type :permanent
|
||||
end
|
||||
|
||||
application :emqx_auto_subscribe do
|
||||
start_type :permanent
|
||||
end
|
||||
|
||||
application :emqx_exhook do
|
||||
start_type :permanent
|
||||
end
|
||||
|
||||
application :emqx_modules do
|
||||
start_type :permanent
|
||||
end
|
||||
|
||||
application :emqx_dashboard do
|
||||
start_type :permanent
|
||||
end
|
||||
|
||||
application :emqx_management do
|
||||
start_type :permanent
|
||||
end
|
||||
|
||||
application :emqx_statsd do
|
||||
start_type :permanent
|
||||
end
|
||||
|
||||
application :emqx_retainer do
|
||||
start_type :permanent
|
||||
end
|
||||
|
||||
application :emqx_rule_engine do
|
||||
start_type :permanent
|
||||
end
|
||||
|
||||
application :emqx_psk do
|
||||
start_type :permanent
|
||||
end
|
||||
|
||||
application :emqx_limiter do
|
||||
start_type :permanent
|
||||
end
|
||||
|
||||
application :emqx_prometheus do
|
||||
start_type :permanent
|
||||
end
|
||||
|
||||
application :bcrypt, %{enable_bcrypt: true, release_type: :cloud} do
|
||||
start_type :permanent
|
||||
end
|
||||
|
||||
application :xmerl, %{release_type: :cloud} do
|
||||
start_type :permanent
|
||||
end
|
||||
|
||||
application :observer, %{release_type: :cloud} do
|
||||
start_type :load
|
||||
end
|
||||
end
|
|
@ -0,0 +1,83 @@
|
|||
defmodule EmqxReleaseHelper.DSL.Application do
|
||||
defmacro __using__(_) do
|
||||
quote do
|
||||
import unquote(__MODULE__)
|
||||
import EmqxReleaseHelper.DSL.Overlay, only: [
|
||||
overlay: 1,
|
||||
overlay: 2,
|
||||
copy: 2,
|
||||
template: 2
|
||||
]
|
||||
Module.register_attribute(__MODULE__, :applications, accumulate: true)
|
||||
@before_compile unquote(__MODULE__)
|
||||
@overlay_source_path :app_source_path
|
||||
end
|
||||
end
|
||||
|
||||
defmacro application(app, condition, do: block) do
|
||||
func =
|
||||
Macro.escape(
|
||||
quote do
|
||||
fn config -> match?(unquote(condition), config) end
|
||||
end
|
||||
)
|
||||
|
||||
quote do
|
||||
@current_application %{name: unquote(app), enable?: unquote(func)}
|
||||
@overlays []
|
||||
unquote(block)
|
||||
overlays = Enum.reverse(@overlays)
|
||||
@applications Map.put(@current_application, :overlays, overlays)
|
||||
@current_application nil
|
||||
@overlays []
|
||||
end
|
||||
end
|
||||
|
||||
defmacro application(app, do: block) do
|
||||
quote do
|
||||
@current_application %{name: unquote(app)}
|
||||
@overlays []
|
||||
unquote(block)
|
||||
overlays = Enum.reverse(@overlays)
|
||||
@applications Map.put(@current_application, :overlays, overlays)
|
||||
@current_application nil
|
||||
@overlays []
|
||||
end
|
||||
end
|
||||
|
||||
defmacro start_type(type) do
|
||||
quote do
|
||||
@current_application Map.put(@current_application, :start_type, unquote(type))
|
||||
end
|
||||
end
|
||||
|
||||
defmacro __before_compile__(%Macro.Env{module: module}) do
|
||||
block =
|
||||
module
|
||||
|> Module.get_attribute(:applications)
|
||||
|> Enum.reverse()
|
||||
|> Enum.map(fn app -> {:%{}, [], Map.to_list(app)} end)
|
||||
|
||||
quote do
|
||||
def __all__, do: unquote(block)
|
||||
|
||||
def run(release, config) do
|
||||
%{project_path: project_path, apps_paths: apps_paths} = config
|
||||
|
||||
__all__()
|
||||
|> Enum.filter(fn %{name: name} -> Map.has_key?(apps_paths, name) end)
|
||||
|> Enum.filter(fn
|
||||
%{enable?: fun} -> fun.(config)
|
||||
_ -> true
|
||||
end)
|
||||
|> Enum.each(fn %{name: name, overlays: overlays} ->
|
||||
app_path = Map.get(apps_paths, name)
|
||||
config = Map.put(config, :app_source_path, Path.join(project_path, app_path))
|
||||
Enum.each(overlays, fn overlay -> overlay.(config) end)
|
||||
end)
|
||||
|
||||
release
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,132 @@
|
|||
defmodule EmqxReleaseHelper.DSL.Overlay do
|
||||
defmacro __using__(_) do
|
||||
quote do
|
||||
import unquote(__MODULE__)
|
||||
@before_compile unquote(__MODULE__)
|
||||
@overlays []
|
||||
@overlay_source_path :project_path
|
||||
end
|
||||
end
|
||||
|
||||
defmacro overlay(do: block) do
|
||||
block =
|
||||
Macro.escape(
|
||||
quote do
|
||||
fn unquote(Macro.var(:config, nil)) ->
|
||||
unquote(block)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
quote do
|
||||
@overlays [unquote(block) | @overlays]
|
||||
end
|
||||
end
|
||||
|
||||
defmacro overlay(literal_config, do: block) do
|
||||
block =
|
||||
Macro.escape(
|
||||
quote do
|
||||
fn unquote(literal_config) = unquote(Macro.var(:config, nil)) ->
|
||||
unquote(block)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
quote do
|
||||
@overlays [unquote(block) | @overlays]
|
||||
end
|
||||
end
|
||||
|
||||
defmacro mkdir(path) do
|
||||
path =
|
||||
quote do
|
||||
unquote(Macro.var(:config, nil))
|
||||
|> Map.get(:release_path)
|
||||
|> Path.join(unquote(path))
|
||||
end
|
||||
|
||||
quote do
|
||||
run_mkdir(unquote(path))
|
||||
end
|
||||
end
|
||||
|
||||
defmacro copy(from_path, to_path) do
|
||||
from_path =
|
||||
quote do
|
||||
unquote(Macro.var(:config, nil))
|
||||
|> Map.get(@overlay_source_path)
|
||||
|> Path.join(unquote(from_path))
|
||||
end
|
||||
|
||||
to_path =
|
||||
quote do
|
||||
unquote(Macro.var(:config, nil))
|
||||
|> Map.get(:release_path)
|
||||
|> Path.join(unquote(to_path))
|
||||
end
|
||||
|
||||
quote do
|
||||
unquote(__MODULE__).run_copy(unquote(from_path), unquote(to_path))
|
||||
end
|
||||
end
|
||||
|
||||
defmacro template(from_path, to_path) do
|
||||
from_path =
|
||||
quote do
|
||||
unquote(Macro.var(:config, nil))
|
||||
|> Map.get(@overlay_source_path)
|
||||
|> Path.join(unquote(from_path))
|
||||
end
|
||||
|
||||
to_path =
|
||||
quote do
|
||||
unquote(Macro.var(:config, nil))
|
||||
|> Map.get(:release_path)
|
||||
|> Path.join(unquote(to_path))
|
||||
end
|
||||
|
||||
quote do
|
||||
unquote(__MODULE__).run_template(
|
||||
unquote(from_path),
|
||||
unquote(to_path),
|
||||
unquote(Macro.var(:config, nil))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def run_mkdir(path) do
|
||||
File.mkdir_p!(path)
|
||||
end
|
||||
|
||||
def run_copy(from_path, to_path) do
|
||||
to_path |> Path.dirname() |> File.mkdir_p!()
|
||||
File.cp_r!(from_path, to_path)
|
||||
end
|
||||
|
||||
def run_template(from_path, to_path, config) do
|
||||
config = Enum.map(config, fn {key, value} -> {to_charlist(key), value} end)
|
||||
to_path |> Path.dirname() |> File.mkdir_p!()
|
||||
|
||||
content =
|
||||
from_path
|
||||
|> File.read!()
|
||||
|> :bbmustache.render(config)
|
||||
|
||||
File.write!(to_path, content)
|
||||
end
|
||||
|
||||
defmacro __before_compile__(%Macro.Env{module: module}) do
|
||||
block =
|
||||
module
|
||||
|> Module.get_attribute(:overlays)
|
||||
|> Enum.reverse()
|
||||
|
||||
quote do
|
||||
def run(release, config) do
|
||||
Enum.each(unquote(block), fn overlay -> overlay.(config) end)
|
||||
release
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,21 @@
|
|||
defmodule EmqxReleaseHelper.Overlay do
|
||||
use EmqxReleaseHelper.DSL.Overlay
|
||||
|
||||
overlay %{release_version: release_version} do
|
||||
mkdir "log"
|
||||
mkdir "etc"
|
||||
mkdir "data"
|
||||
mkdir "data/mnesia"
|
||||
mkdir "data/configs"
|
||||
mkdir "data/patches"
|
||||
mkdir "data/scripts"
|
||||
|
||||
copy "bin/install_upgrade.escript", "bin/install_upgrade.escript"
|
||||
|
||||
copy "bin/node_dump", "bin/node_dump"
|
||||
copy "bin/emqx_ctl", "bin/emqx_ctl"
|
||||
|
||||
template "data/emqx_vars", "releases/emqx_vars"
|
||||
template "data/BUILT_ON", "releases/#{release_version}/BUILT_ON"
|
||||
end
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
defmodule EmqxReleaseHelper.Script do
|
||||
def run(release, config) do
|
||||
script_path = Path.join(config.project_path, "scripts")
|
||||
|
||||
{_, 0} =
|
||||
script_path
|
||||
|> Path.join("merge-config.escript")
|
||||
|> System.cmd([])
|
||||
|
||||
{_, 0} =
|
||||
script_path
|
||||
|> Path.join("get-dashboard.sh")
|
||||
|> System.cmd([], env: [{"EMQX_DASHBOARD_VERSION", "v5.0.0-beta.13"}])
|
||||
|
||||
release
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
defmodule EMQXReleaseHelper.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :emqx_release_helper,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps()
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:bbmustache, "1.12.1"}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
defmodule EmqxReleaseHelperTest do
|
||||
use ExUnit.Case
|
||||
doctest EmqxReleaseHelper
|
||||
|
||||
test "greets the world" do
|
||||
assert EmqxReleaseHelper.hello() == :world
|
||||
end
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
ExUnit.start()
|
|
@ -0,0 +1,4 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue