Skip to content

Commit 2dd70bb

Browse files
committed
ops:add production rmqtt config
1 parent e0f226c commit 2dd70bb

File tree

7 files changed

+261
-5
lines changed

7 files changed

+261
-5
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
交互协议走 json 字符串。
1414
```json5
1515
# Web websocket-mqtt send
16-
# publish topic: $clientId/cmd
16+
# publish topic: cmd/$clientId
1717
{
1818
cmd: "ls",
1919
requestId: "random_to_track",
2020
#stream: false, # can be empty, default is false. this project now only support false.
2121
}
2222

2323
# mproxy response
24-
# publish topic: $client/cmd/resp
24+
# publish topic: cmd/$client/resp
2525
# success response
2626
{
2727
type: "Ok"
@@ -46,13 +46,13 @@ Install [Rust 1.70+](https://www.rust-lang.org/),
4646
[mprocs](https://github.com/pvolok/mprocs). Then, run
4747
```shell
4848
cd web && npm ci && cd ../
49-
cd develop && ./run_mqtt.sh && cd ../
49+
cd shell && ./run_mqtt.sh && cd ../
5050
mprocs
5151

52-
# this is check MQTT agent if is OK
52+
# Check MQTT agent if is OK
5353
cd agent && cargo run --example publish_command.rs
5454
```
55-
Web [Figma UI](https://www.figma.com/design/iyL4dms3B8AWGZS14FCRuf/RMQTT-EXEC?m=dev&node-id=0%3A1&t=aXOx1pkofASiwbPa-1)
55+
Web [Figma UI](https://www.figma.com/design/iyL4dms3B8AWGZS14FCRuf/RMQTT-EXEC?node-id=0%3A1&t=rnIL1LSWwQIXfZdf-1)
5656
## 限制
5757
目前只支持普通的命令, 不支持 `sudo xxx` 之类命令。
5858

shell/prod/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## RMQTT Production Config
2+
3+
相比于开发配置:
4+
1. 禁用了 websocket socket。
5+
2. 在 rmqtt-acl 添加了简单的权限配置。

shell/prod/plugin/rmqtt-acl.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
##--------------------------------------------------------------------
2+
## rmqtt-acl
3+
##--------------------------------------------------------------------
4+
5+
disconnect_if_pub_rejected = true
6+
7+
rules = [
8+
#["allow", { user = "dashboard" }, "subscribe", ["$SYS/#"]],
9+
["allow", { ipaddr = "127.0.0.1" }, "pubsub", ["$SYS/#", "#"]],
10+
#["deny", "all", "subscribe", ["$SYS/#", { eq = "#" }]],
11+
# set superuser to publish shell command
12+
["allow", { user = "timzaak", password = "timzaak", superuser = true }],
13+
# allow nodes to publish/subscribe shell command
14+
["allow", { user = "nodes", password ="nodes_password" }, "pubsub", ["cmd/%c", "cmd/%c/resp"]],
15+
["deny", "all"]
16+
]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
##--------------------------------------------------------------------
2+
## rmqtt-http-api
3+
##--------------------------------------------------------------------
4+
5+
# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/http-api.md
6+
7+
##Number of worker threads
8+
workers = 1
9+
## Max Row Limit
10+
max_row_limit = 10_000
11+
## HTTP Listener
12+
http_laddr = "0.0.0.0:6060"
13+
## Indicates whether to print HTTP request logs
14+
http_request_log = false
15+
16+
##Whether support retain message, true/false, default value: true
17+
message_retain_available = false
18+
##Whether support storage messages, true/false, default value: false
19+
message_storage_available = false
20+
##Message expiration time, 0 means no expiration
21+
message_expiry_interval = "5m"

shell/prod/rmqtt.toml

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
##--------------------------------------------------------------------
2+
## General
3+
##--------------------------------------------------------------------
4+
5+
##--------------------------------------------------------------------
6+
## Task
7+
##--------------------------------------------------------------------
8+
#Concurrent task count for global task executor.
9+
task.exec_workers = 200
10+
#Queue capacity for global task executor.
11+
task.exec_queue_max = 3_000
12+
#Concurrent task count for global local task executor, per worker thread.
13+
task.local_exec_workers = 5
14+
#Queue capacity for global local task executor, per worker thread.
15+
task.local_exec_queue_max = 1_000
16+
#The rate at which messages are dequeued from the 'LocalTaskExecQueue' message queue, per worker thread.
17+
#default value: "u32::MAX,1s"
18+
task.local_exec_rate_limit = "100,1s"
19+
20+
21+
##--------------------------------------------------------------------
22+
## Node
23+
##--------------------------------------------------------------------
24+
#Node id
25+
node.id = 1
26+
27+
#Busy status check switch.
28+
#default value: true
29+
node.busy.check_enable = true
30+
#Busy status update interval.
31+
#default value: 2s
32+
node.busy.update_interval = "2s"
33+
#The threshold for the 1-minute average system load used to determine system busyness.
34+
#Value range: 0.0-100.0, default value: 80.0
35+
node.busy.loadavg = 80.0
36+
#The threshold for average CPU load used to determine system busyness.
37+
#Value range: 0.0-100.0, default value: 90.0
38+
node.busy.cpuloadavg = 90.0
39+
#The threshold for determining high-concurrency connection handshakes in progress.
40+
node.busy.handshaking = 0
41+
42+
##--------------------------------------------------------------------
43+
## RPC
44+
##--------------------------------------------------------------------
45+
#rpc.server_addr = "0.0.0.0:5363"
46+
#rpc.server_workers = 4
47+
#Maximum number of messages sent in batch
48+
#rpc.batch_size = 128
49+
#Client concurrent request limit
50+
#rpc.client_concurrency_limit = 128
51+
#Connect and send to server timeout
52+
#rpc.client_timeout = "10s"
53+
54+
55+
##--------------------------------------------------------------------
56+
## Log
57+
##--------------------------------------------------------------------
58+
# Value: off | file | console | both
59+
log.to = "file"
60+
# Value: trace, debug, info, warn, error
61+
log.level = "debug"
62+
log.dir = "/var/log/rmqtt"
63+
log.file = "rmqtt.log"
64+
65+
66+
##--------------------------------------------------------------------
67+
## Plugins
68+
##--------------------------------------------------------------------
69+
#Plug in configuration file directory
70+
plugins.dir = "plugin/"
71+
#Plug in started by default, when the mqtt server is started
72+
plugins.default_startups = [
73+
#"rmqtt-plugin-template",
74+
#"rmqtt-retainer",
75+
#"rmqtt-auth-http",
76+
#"rmqtt-cluster-broadcast",
77+
#"rmqtt-cluster-raft",
78+
#"rmqtt-sys-topic",
79+
#"rmqtt-message-storage",
80+
#"rmqtt-session-storage",
81+
#"rmqtt-web-hook",
82+
#"rmqtt-http-api"
83+
]
84+
85+
86+
##--------------------------------------------------------------------
87+
## MQTT
88+
##--------------------------------------------------------------------
89+
90+
91+
##--------------------------------------------------------------------
92+
## Listeners
93+
##--------------------------------------------------------------------
94+
95+
##--------------------------------------------------------------------
96+
## MQTT/TCP - External TCP Listener for MQTT Protocol
97+
listener.tcp.external.addr = "0.0.0.0:1883"
98+
#Number of worker threads
99+
listener.tcp.external.workers = 8
100+
#The maximum number of concurrent connections allowed by the listener.
101+
listener.tcp.external.max_connections = 1024000
102+
#Maximum concurrent handshake limit, Default: 500
103+
listener.tcp.external.max_handshaking_limit = 500
104+
#Handshake timeout.
105+
listener.tcp.external.handshake_timeout = "30s"
106+
#Maximum allowed mqtt message length. 0 means unlimited, default: 1m
107+
listener.tcp.external.max_packet_size = "1m"
108+
#The maximum length of the TCP connection queue.
109+
#It indicates the maximum number of TCP connection queues that are being handshaked three times in the system
110+
listener.tcp.external.backlog = 1024
111+
#Whether anonymous login is allowed. Default: true
112+
listener.tcp.external.allow_anonymous = true
113+
#A value of zero indicates disabling the keep-alive feature, where the server
114+
#doesn't need to disconnect due to client inactivity, default: true
115+
listener.tcp.external.allow_zero_keepalive = true
116+
#Minimum allowable keepalive value for mqtt connection,
117+
#less than this value will reject the connection(MQTT V3),
118+
#less than this value will set keepalive to this value in CONNACK (MQTT V5),
119+
#default: 0, unit: seconds
120+
listener.tcp.external.min_keepalive = 0
121+
#Maximum allowable keepalive value for mqtt connection,
122+
#greater than this value will reject the connection(MQTT V3),
123+
#greater than this value will set keepalive to this value in CONNACK (MQTT V5),
124+
#default value: 65535, unit: seconds
125+
listener.tcp.external.max_keepalive = 65535
126+
# > 0.5, Keepalive * backoff * 2
127+
listener.tcp.external.keepalive_backoff = 0.75
128+
#Flight window size. The flight window is used to store the unanswered QoS 1 and QoS 2 messages
129+
listener.tcp.external.max_inflight = 16
130+
#Maximum length of message queue
131+
listener.tcp.external.max_mqueue_len = 1000
132+
#The rate at which messages are ejected from the message queue,
133+
#default value: "u32::max_value(),1s"
134+
listener.tcp.external.mqueue_rate_limit = "1000,1s"
135+
#Maximum length of client ID allowed, Default: 65535
136+
listener.tcp.external.max_clientid_len = 65535
137+
#The maximum QoS level that clients are allowed to publish. default value: 2
138+
listener.tcp.external.max_qos_allowed = 2
139+
#The maximum level at which clients are allowed to subscribe to topics.
140+
#0 means unlimited. default value: 0
141+
listener.tcp.external.max_topic_levels = 0
142+
#Whether support retain message, true/false, default value: false
143+
listener.tcp.external.retain_available = false
144+
#Session timeout, default value: 2 hours
145+
listener.tcp.external.session_expiry_interval = "2h"
146+
#QoS 1/2 message retry interval, 0 means no resend
147+
listener.tcp.external.message_retry_interval = "20s"
148+
#Message expiration time, 0 means no expiration
149+
listener.tcp.external.message_expiry_interval = "5m"
150+
#The maximum number of topics that a single client is allowed to subscribe to
151+
#0 means unlimited, default value: 0
152+
listener.tcp.external.max_subscriptions = 0
153+
#Shared subscription switch, default value: true
154+
listener.tcp.external.shared_subscription = true
155+
#topic alias maximum, default value: 0, topic aliases not enabled. (MQTT 5.0)
156+
listener.tcp.external.max_topic_aliases = 32
157+
158+
##--------------------------------------------------------------------
159+
## Internal TCP Listener for MQTT Protocol
160+
#listener.tcp.internal.enable = true
161+
#listener.tcp.internal.addr = "0.0.0.0:11883"
162+
#listener.tcp.internal.workers = 4
163+
#listener.tcp.internal.max_connections = 102400
164+
#listener.tcp.internal.max_handshaking_limit = 500
165+
#listener.tcp.internal.handshake_timeout = "30s"
166+
#listener.tcp.internal.max_packet_size = "1M"
167+
#listener.tcp.internal.backlog = 512
168+
#listener.tcp.internal.allow_anonymous = true
169+
#listener.tcp.internal.allow_zero_keepalive = true
170+
#listener.tcp.internal.min_keepalive = 0
171+
#listener.tcp.internal.max_keepalive = 65535
172+
#listener.tcp.internal.keepalive_backoff = 0.75
173+
#listener.tcp.internal.max_inflight = 16
174+
#listener.tcp.internal.max_mqueue_len = 1000
175+
#listener.tcp.internal.mqueue_rate_limit = "1000,1s"
176+
#listener.tcp.internal.max_clientid_len = 65535
177+
#listener.tcp.internal.max_qos_allowed = 2
178+
#listener.tcp.internal.max_topic_levels = 0
179+
#listener.tcp.internal.retain_available = false
180+
#listener.tcp.internal.session_expiry_interval = "2h"
181+
#listener.tcp.internal.message_retry_interval = "30s"
182+
#listener.tcp.internal.message_expiry_interval = "5m"
183+
#listener.tcp.internal.max_subscriptions = 0
184+
#listener.tcp.internal.shared_subscription = true
185+
#listener.tcp.internal.max_topic_aliases = 0
186+
187+
##--------------------------------------------------------------------
188+
## MQTT/TLS - External TLS Listener for MQTT Protocol, (TLSv1.2)
189+
#listener.tls.external.addr = "0.0.0.0:8883"
190+
#listener.tls.external.cross_certificate = true
191+
#listener.tls.external.cert = "./rmqtt-bin/rmqtt.fullchain.pem"
192+
#listener.tls.external.cross_certificate = false
193+
#listener.tls.external.cert = "./rmqtt-bin/rmqtt.pem"
194+
#listener.tls.external.key = "./rmqtt-bin/rmqtt.key"
195+
196+
##--------------------------------------------------------------------
197+
## MQTT/WebSocket - External WebSocket Listener for MQTT Protocol
198+
#listener.ws.external.addr = "0.0.0.0:8080"
199+
200+
##--------------------------------------------------------------------
201+
## MQTT/TLS-WebSocket - External TLS-WebSocket Listener for MQTT Protocol, (TLSv1.2)
202+
#listener.wss.external.addr = "0.0.0.0:8443"
203+
#listener.wss.external.cross_certificate = true
204+
#listener.wss.external.cert = "./rmqtt-bin/rmqtt.fullchain.pem"
205+
#listener.wss.external.cross_certificate = false
206+
#listener.wss.external.cert = "./rmqtt-bin/rmqtt.pem"
207+
#listener.wss.external.key = "./rmqtt-bin/rmqtt.key"

shell/prod/run_prod_mqtt.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
#-p 6060:6060 -p 1883:1883
3+
docker run -d --name rmqtt --network=host \
4+
-v $(pwd)/rmqtt/rmqtt.toml:/app/rmqtt/rmqtt.toml \
5+
-v $(pwd)/rmqtt/plugin:/app/rmqtt/plugin \
6+
-v $(pwd)/rmqtt/log:/var/log/rmqtt \
7+
rmqtt/rmqtt:latest

shell/rmqtt/plugin/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)