Feng Lee 10 лет назад
Родитель
Сommit
859ec60acc
2 измененных файлов с 480 добавлено и 0 удалено
  1. 244 0
      rel/files/emqttd.config.development
  2. 236 0
      rel/files/emqttd.config.production

+ 244 - 0
rel/files/emqttd.config.development

@@ -0,0 +1,244 @@
+% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ft=erlang ts=4 sw=4 et
+[{kernel, 
+	[{start_timer, true},
+	 {start_pg2, true}
+ ]},
+ {sasl, [
+	{sasl_error_logger, {file, "log/emqttd_sasl.log"}}
+ ]},
+ {ssl, [
+    %{versions, ['tlsv1.2', 'tlsv1.1']}
+ ]},
+ {lager, [
+    {colored, true},
+    {async_threshold, 1000},
+	{error_logger_redirect, false},
+	{crash_log, "log/emqttd_crash.log"},
+	{handlers, [
+		{lager_console_backend, info},
+		{lager_file_backend, [
+            {formatter_config, [time, " ", pid, " [",severity,"] ", message, "\n"]},
+			{file, "log/emqttd_info.log"},
+			{level, info},
+			{size, 104857600},
+			{date, "$D0"},
+			{count, 30}
+		]},
+		{lager_file_backend, [
+            {formatter_config, [time, " ", pid, " [",severity,"] ", message, "\n"]},
+			{file, "log/emqttd_error.log"},
+			{level, error},
+			{size, 104857600},
+			{date, "$D0"},
+			{count, 30}
+		]}
+	]}
+ ]},
+ {esockd, [
+    {logger, {lager, info}}
+ ]},
+ {emqttd, [
+    %% Authentication and Authorization
+    {access, [
+        %% Authetication. Anonymous Default
+        {auth, [
+            %% Authentication with username, password
+            %{username, []},
+            
+            %% Authentication with clientid
+            %{clientid, [{password, no}, {file, "etc/clients.config"}]},
+
+            %% Authentication with LDAP
+            % {ldap, [
+            %    {servers, ["localhost"]},
+            %    {port, 389},
+            %    {timeout, 30},
+            %    {user_dn, "uid=$u,ou=People,dc=example,dc=com"},
+            %    {ssl, fasle},
+            %    {sslopts, [
+            %        {"certfile", "ssl.crt"},
+            %        {"keyfile", "ssl.key"}]}
+            % ]},
+
+            %% Allow all
+            {anonymous, []}
+        ]},
+        %% ACL config
+        {acl, [
+            %% Internal ACL module
+            {internal,  [{file, "etc/acl.config"}, {nomatch, allow}]}
+        ]}
+    ]},
+    %% MQTT Protocol Options
+    {mqtt, [
+        %% Packet
+        {packet, [
+            %% Max ClientId Length Allowed
+            {max_clientid_len, 1024},
+            %% Max Packet Size Allowed, 64K default
+            {max_packet_size,  65536}
+        ]},
+        %% Client
+        {client, [
+            %TODO: Network ingoing limit
+            %{ingoing_rate_limit, '64KB/s'}
+            %TODO: Reconnet control
+        ]},
+        %% Session
+        {session, [
+            %% Max number of QoS 1 and 2 messages that can be “in flight” at one time.
+            %% 0 means no limit
+            {max_inflight, 100},
+
+            %% Max retries for unack Qos1/2 messages
+            {unack_retries, 3},
+
+            %% Retry after 4, 8, 16 seconds
+            {unack_timeout, 4},
+
+            %% Awaiting PUBREL Timeout
+            {await_rel_timeout, 8},
+
+            %% Max Packets that Awaiting PUBREL, 0 means no limit
+            {max_awaiting_rel, 0},
+
+            %% Statistics Collection Interval(seconds)
+            {collect_interval, 10},
+
+            %% Expired after 2 days
+            {expired_after, 48}
+
+        ]},
+        %% Session
+        {queue, [
+            %% Max queue length. enqueued messages when persistent client disconnected, 
+            %% or inflight window is full.
+            {max_length, 100},
+
+            %% Low-water mark of queued messsages
+            {low_watermark, 0.2},
+
+            %% High-water mark of queued messsages
+            {high_watermark, 0.6},
+
+            %% Queue Qos0 messages?
+            {queue_qos0, true}
+        ]}
+    ]},
+    %% Broker Options
+    {broker, [
+        %% System interval of publishing broker $SYS messages
+        {sys_interval, 60},
+
+        %% Retained messages
+        {retained, [
+            %% Max number of retained messages
+            {max_message_num, 100000},
+            %% Max Payload Size of retained message
+            {max_playload_size, 65536}
+        ]},
+        %% PubSub
+        {pubsub, [
+            %% default should be scheduler numbers
+            %% {pool_size, 8}
+        ]},
+        %% Bridge
+        {bridge, [
+            %%TODO: bridge queue size
+            {max_queue_len, 10000},
+
+            %% Ping Interval of bridge node
+            {ping_down_interval, 1} %seconds
+        ]}
+    ]},
+    %% Modules
+    {modules, [
+        %% Client presence management module.
+        %% Publish messages when client connected or disconnected
+        {presence, [{qos, 0}]}
+
+        %% Subscribe topics automatically when client connected
+        %% {autosub, [{"$Q/client/$c", 0}]}
+
+        %% Rewrite rules
+        %% {rewrite, [{file, "etc/rewrite.config"}]}
+        
+    ]},
+    %% Plugins
+    {plugins, [
+        %% Plugin App Library Dir
+        {plugins_dir, "./plugins"},
+
+        %% File to store loaded plugin names.
+        {loaded_file, "./data/loaded_plugins"}
+    ]},
+    %% Listeners
+    {listeners, [
+        {mqtt, 1883, [
+            %% Size of acceptor pool
+            {acceptors, 16},
+            %% Maximum number of concurrent clients
+            {max_clients, 512},
+            %% Socket Access Control
+            {access, [{allow, all}]},
+            %% Socket Options
+            {sockopts, [
+                {backlog, 512}
+                %Set buffer if hight thoughtput
+                %{recbuf, 4096},
+                %{sndbuf, 4096}
+                %{buffer, 4096},
+            ]}
+        ]},
+        {mqtts, 8883, [
+            %% Size of acceptor pool
+            {acceptors, 4},
+            %% Maximum number of concurrent clients
+            {max_clients, 512},
+            %% Socket Access Control
+            {access, [{allow, all}]},
+            %% SSL certificate and key files
+            {ssl, [{certfile, "etc/ssl/ssl.crt"},
+                   {keyfile,  "etc/ssl/ssl.key"}]},
+            %% Socket Options
+            {sockopts, [
+                {backlog, 1024}
+                %{buffer, 4096},
+            ]}
+        ]},
+        %% WebSocket over HTTPS Listener
+        %% {https, 8083, [
+        %%  %% Size of acceptor pool
+        %%  {acceptors, 4},
+        %%  %% Maximum number of concurrent clients
+        %%  {max_clients, 512},
+        %%  %% Socket Access Control
+        %%  {access, [{allow, all}]},
+        %%  %% SSL certificate and key files
+        %%  {ssl, [{certfile, "etc/ssl/ssl.crt"},
+        %%         {keyfile,  "etc/ssl/ssl.key"}]},
+        %%  %% Socket Options
+        %%  {sockopts, [
+        %%      %{buffer, 4096},
+        %%      {backlog, 1024}
+        %%  ]}
+        %%]},
+        %% HTTP and WebSocket Listener
+        {http, 8083, [
+            %% Size of acceptor pool
+            {acceptors, 4},
+            %% Maximum number of concurrent clients
+            {max_clients, 64},
+            %% Socket Access Control
+            {access, [{allow, all}]},
+            %% Socket Options
+            {sockopts, [
+                {backlog, 1024}
+                %{buffer, 4096},
+            ]}
+        ]}
+    ]}
+ ]}
+].
+

+ 236 - 0
rel/files/emqttd.config.production

@@ -0,0 +1,236 @@
+% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ft=erlang ts=4 sw=4 et
+[{kernel, 
+	[{start_timer, true},
+	 {start_pg2, true}
+ ]},
+ {sasl, [
+	{sasl_error_logger, {file, "log/emqttd_sasl.log"}}
+ ]},
+ {ssl, [
+    %{versions, ['tlsv1.2', 'tlsv1.1']}
+ ]},
+ {lager, [
+    {colored, true},
+    {async_threshold, 5000},
+	{error_logger_redirect, false},
+	{crash_log, "log/emqttd_crash.log"},
+	{handlers, [
+		{lager_console_backend, info},
+		{lager_file_backend, [
+            {formatter_config, [time, " ", pid, " [",severity,"] ", message, "\n"]},
+			{file, "log/emqttd_error.log"},
+			{level, error},
+			{size, 104857600},
+			{date, "$D0"},
+			{count, 30}
+		]}
+	]}
+ ]},
+ {esockd, [
+    {logger, {lager, error}}
+ ]},
+ {emqttd, [
+    %% Authentication and Authorization
+    {access, [
+        %% Authetication. Anonymous Default
+        {auth, [
+            %% Authentication with username, password
+            %{username, []},
+            
+            %% Authentication with clientid
+            %{clientid, [{password, no}, {file, "etc/clients.config"}]},
+
+            %% Authentication with LDAP
+            % {ldap, [
+            %    {servers, ["localhost"]},
+            %    {port, 389},
+            %    {timeout, 30},
+            %    {user_dn, "uid=$u,ou=People,dc=example,dc=com"},
+            %    {ssl, fasle},
+            %    {sslopts, [
+            %        {"certfile", "ssl.crt"},
+            %        {"keyfile", "ssl.key"}]}
+            % ]},
+
+            %% Allow all
+            {anonymous, []}
+        ]},
+        %% ACL config
+        {acl, [
+            %% Internal ACL module
+            {internal,  [{file, "etc/acl.config"}, {nomatch, allow}]}
+        ]}
+    ]},
+    %% MQTT Protocol Options
+    {mqtt, [
+        %% Packet
+        {packet, [
+            %% Max ClientId Length Allowed
+            {max_clientid_len, 1024},
+            %% Max Packet Size Allowed, 64K default
+            {max_packet_size,  65536}
+        ]},
+        %% Client
+        {client, [
+            %TODO: Network ingoing limit
+            %{ingoing_rate_limit, '64KB/s'}
+            %TODO: Reconnet control
+        ]},
+        %% Session
+        {session, [
+            %% Max number of QoS 1 and 2 messages that can be “in flight” at one time.
+            %% 0 means no limit
+            {max_inflight, 100},
+
+            %% Max retries for unack Qos1/2 messages
+            {unack_retries, 3},
+
+            %% Retry after 8, 16, 32 seconds
+            {unack_timeout, 8},
+
+            %% Awaiting PUBREL Timeout
+            {await_rel_timeout, 8},
+
+            %% Max Packets that Awaiting PUBREL, 0 means no limit
+            {max_awaiting_rel, 0},
+
+            %% Statistics Collection Interval(seconds)
+            {collect_interval, 20},
+
+            %% Expired after 2 days
+            {expired_after, 48}
+
+        ]},
+        %% Session
+        {queue, [
+            %% Max queue length. enqueued messages when persistent client disconnected, 
+            %% or inflight window is full.
+            {max_length, 100},
+
+            %% Low-water mark of queued messsages
+            {low_watermark, 0.2},
+
+            %% High-water mark of queued messsages
+            {high_watermark, 0.6},
+
+            %% Queue Qos0 messages?
+            {queue_qos0, true}
+        ]}
+    ]},
+    %% Broker Options
+    {broker, [
+        %% System interval of publishing broker $SYS messages
+        {sys_interval, 60},
+
+        %% Retained messages
+        {retained, [
+            %% Max number of retained messages
+            {max_message_num, 100000},
+            %% Max Payload Size of retained message
+            {max_playload_size, 65536}
+        ]},
+        %% PubSub
+        {pubsub, [
+            %% default should be scheduler numbers
+            {pool_size, 8}
+        ]},
+        %% Bridge
+        {bridge, [
+            %%TODO: bridge queue size
+            {max_queue_len, 10000},
+
+            %% Ping Interval of bridge node
+            {ping_down_interval, 1} %seconds
+        ]}
+    ]},
+    %% Modules
+    {modules, [
+        %% Client presence management module.
+        %% Publish messages when client connected or disconnected
+        {presence, [{qos, 0}]}
+
+        %% Subscribe topics automatically when client connected
+        %% {autosub, [{"$Q/client/$c", 0}]}
+
+        %% Rewrite rules
+        %% {rewrite, [{file, "etc/rewrite.config"}]}
+        
+    ]},
+    %% Plugins
+    {plugins, [
+        %% Plugin App Library Dir
+        {plugins_dir, "./plugins"},
+
+        %% File to store loaded plugin names.
+        {loaded_file, "./data/loaded_plugins"}
+    ]},
+    %% Listeners
+    {listeners, [
+        {mqtt, 1883, [
+            %% Size of acceptor pool
+            {acceptors, 16},
+            %% Maximum number of concurrent clients
+            {max_clients, 8192},
+            %% Socket Access Control
+            {access, [{allow, all}]},
+            %% Socket Options
+            {sockopts, [
+                {backlog, 512}
+                %Set buffer if hight thoughtput
+                %{recbuf, 4096},
+                %{sndbuf, 4096}
+                %{buffer, 4096},
+            ]}
+        ]},
+        {mqtts, 8883, [
+            %% Size of acceptor pool
+            {acceptors, 4},
+            %% Maximum number of concurrent clients
+            {max_clients, 512},
+            %% Socket Access Control
+            {access, [{allow, all}]},
+            %% SSL certificate and key files
+            {ssl, [{certfile, "etc/ssl/ssl.crt"},
+                   {keyfile,  "etc/ssl/ssl.key"}]},
+            %% Socket Options
+            {sockopts, [
+                {backlog, 1024}
+                %{buffer, 4096},
+            ]}
+        ]},
+        %% WebSocket over HTTPS Listener
+        %% {https, 8083, [
+        %%  %% Size of acceptor pool
+        %%  {acceptors, 4},
+        %%  %% Maximum number of concurrent clients
+        %%  {max_clients, 512},
+        %%  %% Socket Access Control
+        %%  {access, [{allow, all}]},
+        %%  %% SSL certificate and key files
+        %%  {ssl, [{certfile, "etc/ssl/ssl.crt"},
+        %%         {keyfile,  "etc/ssl/ssl.key"}]},
+        %%  %% Socket Options
+        %%  {sockopts, [
+        %%      %{buffer, 4096},
+        %%      {backlog, 1024}
+        %%  ]}
+        %%]},
+        %% HTTP and WebSocket Listener
+        {http, 8083, [
+            %% Size of acceptor pool
+            {acceptors, 4},
+            %% Maximum number of concurrent clients
+            {max_clients, 64},
+            %% Socket Access Control
+            {access, [{allow, all}]},
+            %% Socket Options
+            {sockopts, [
+                {backlog, 1024}
+                %{buffer, 4096},
+            ]}
+        ]}
+    ]}
+ ]}
+].
+