<file name="emqx.config">
%%
%%  emqx.config -- emqx(8) configuration
%%

[{kernel,
    [{start_timer, true},
     {start_pg2, true}
 ]},
 {sasl, [
    {sasl_error_logger, {file, "@l_prefix@/var/emqx/log/emqx-sasl.log"}}
 ]},
 {ssl, [
    {versions, ['tlsv1.2', 'tlsv1.1']}
 ]},
 {lager, [
    {colored, true},
    {async_threshold, 5000},
    {error_logger_redirect, false},
    {crash_log, "@l_prefix@/var/emqx/log/emqx-crash.log"},
    {handlers, [
        {lager_file_backend, [
            {formatter_config, [time, " ", pid, " [",severity,"] ", message, "\n"]},
            {file, "@l_prefix@/var/emqx/log/emqx-error.log"},
            {level, error},
            {size, 104857600},
            {date, "$D0"},
            {count, 30}
        ]}
    ]}
 ]},
 {esockd, [
    {logger, {lager, error}}
 ]},
 {emqx, [
    {access, [
        {auth, [
            %{username, []},
            %{clientid, [{password, no}, {file, "@l_prefix@/etc/emqx/emqx-clients.config"}]},
            {anonymous, []}
        ]},
        {acl, [
            {internal,  [{file, "@l_prefix@/etc/emqx/emqx-acl.config"}, {nomatch, allow}]}
        ]}
    ]},
    {mqtt, [
        {packet, [
            {max_clientid_len, 1024},
            {max_packet_size,  65536}
        ]},
        {client, [
            {idle_timeout, 20}
            %{ingoing_rate_limit, '64KB/s'}
        ]},
        {session, [
            {max_inflight, 100},
            {unack_retry_interval, 60},
            {await_rel_timeout, 20},
            {max_awaiting_rel, 0},
            {collect_interval, 0},
            {expired_after, 48}
        ]},
        {queue, [
            {max_length, 100},
            {low_watermark, 0.2},
            {high_watermark, 0.6},
            {queue_qos0, true}
        ]}
    ]},
    {broker, [
        {sys_interval, 60},
        {retained, [
            {expired_after, 0},
            {max_message_num, 100000},
            {max_playload_size, 65536}
        ]},
        {pubsub, [
            %{pool_size, 8}
        ]},
        {bridge, [
            {max_queue_len, 10000},
            {ping_down_interval, 1}
        ]}
    ]},
    {modules, [
        {presence, [{qos, 0}]}
        %{autosub, [{"$Q/client/$c", 0}]}
        %{rewrite, [{file, "@l_prefix@/etc/emqx/emqx-rewrite.config"}]}
    ]},
    {plugins, [
        {plugins_dir, "@l_prefix@/libexec/emqx/plugins"},
        {loaded_file, "@l_prefix@/var/emqx/data/loaded_plugins"}
    ]},
    {listeners, [
        {mqtt, 1883, [
            {acceptors, 16},
            {max_clients, 8192},
            {access, [{allow, all}]},
            {connopts, [
                %{rate_limit, "100,10"} %% 100K burst, 10K rate
            ]},
            {sockopts, [
                %{recbuf, 4096},
                %{sndbuf, 4096},
                %{buffer, 4096},
                %{nodelay, true},
                {backlog, 1024}
            ]}
        ]},
        {mqtts, 8883, [
            {acceptors, 4},
            {max_clients, 512},
            {access, [{allow, all}]},
            {ssl, [{certfile, "@l_prefix@/etc/x509/example-server.crt.pem"},
                   {keyfile,  "@l_prefix@/etc/x509/example-server.key.pem"}]},
            {sockopts, [
                {backlog, 1024}
                %{buffer, 4096},
            ]}
        ]},
        {https, 8443, [
          {acceptors, 4},
          {max_clients, 512},
          {access, [{allow, all}]},
          {ssl, [{certfile, "@l_prefix@/etc/x509/example-server.crt.pem"},
                 {keyfile,  "@l_prefix@/etc/x509/example-server.key.pem"}]},
          {sockopts, [
              %{buffer, 4096},
              {backlog, 1024}
          ]}
        ]},
        {http, 8083, [
            {acceptors, 4},
            {max_clients, 64},
            {access, [{allow, all}]},
            {sockopts, [
                {backlog, 1024}
                %{buffer, 4096},
            ]}
        ]},
        {emqx_stomp, 61613, [
            {acceptors, 4},
            {max_clients, 512}
        ]},
        {emqx_dashboard, 18083, [
            {acceptors, 4},
            {max_clients, 512}
        ]}
    ]},
    {sysmon, [
        {long_gc, false},
        {long_schedule, 100},
        {large_heap, 8388608},
        {busy_port, true},
        {busy_dist_port, true}
    ]}
 ]}
].
</file>
<file name="emqx-acl.config">
%%
%%  emqx-acl.config
%%  https://github.com/emqtt/emqx/wiki/ACL
%%
%%  -type who() :: all | binary() |
%%                 {ipaddr, esockd_access:cidr()} |
%%                 {client, binary()} |
%%                 {user, binary()}.
%%  -type access() :: subscribe | publish | pubsub.
%%  -type topic() :: binary().
%%  -type rule() :: {allow, all} |
%%                  {allow, who(), access(), list(topic())} |
%%                  {deny, all} |
%%                  {deny, who(), access(), list(topic())}.
%%

{allow, {user, "dashboard"}, subscribe, ["$SYS/#"]}.

{allow, {ipaddr, "127.0.0.1"}, pubsub, ["$SYS/#", "#"]}.

{deny, all, subscribe, ["$SYS/#", {eq, "#"}]}.

{allow, all}.

</file>
<file name="emqx-client.config">
client1
client2 127.0.0.1
client2 192.168.0.1/24
</file>
<file name="emqx-rewrite.config">
%%
%%   emqx-rewrite.config
%%   https://github.com/emqtt/emqx/wiki/Rewrite
%%

%{topic, "x/#", [
%    {rewrite, "^x/y/(.+)$", "z/y/$1"},
%    {rewrite, "^x/(.+)$", "y/$1"}
%]}.

%{topic, "y/+/z/#", [
%    {rewrite, "^y/(.+)/z/(.+)$", "y/z/$2"}
%]}.

</file>
<file name="vm.args">
##
##  vm.args -- Erlang Virtual Machine configuration
##

-name emqx@127.0.0.1
-setcookie emqxsecretcookie

#-heart
-smp true
+K true
+A 48
+P 8192
+Q 8192
#+t
#+zdbbl 8192

-env ERL_MAX_PORTS 8192
-env ERTS_MAX_PORTS 8192
-env ERL_MAX_ETS_TABLES 1024
-env ERL_FULLSWEEP_AFTER 1000

</file>
