11 releases (6 breaking)
| 0.21.0 | May 30, 2026 |
|---|---|
| 0.19.1 | Mar 29, 2026 |
| 0.18.1 | Dec 8, 2025 |
| 0.18.0 | Nov 30, 2025 |
#5 in #mqtt-server
625KB
12K
SLoC
rmqttd
Official binary entry point for the RMQTT MQTT broker.
What it does
- Startup flow: Parse CLI args → initialize
rmqtt_conf::Settingssingleton → install rustls crypto backend → init tracing logger → creatermqtt::context::ServerContext→ start gRPC server → register plugins fromCargo.tomlmetadata → bind configured listeners → start MQTT server - Build-time plugin registration:
build.rsreads[package.metadata.plugins]fromCargo.toml, auto-generatesplugin.rswith aregisters()function. Each plugin is registered based ondefault_startupandimmutableflags - Listener types: TCP, TLS, WebSocket (WS), TLS-WebSocket (WSS), QUIC
- Signal handling:
Ctrl+Con Windows,SIGTERM+SIGINTon Unix; 100ms graceful delay before exit - Logging: Configured via
rmqtt_conf::logging::Log— supportsoff/console/file/bothmodes, UTC+8 timestamps, non-blocking file writer - Linux allocator: Uses
tikv-jemallocatoras the default memory allocator on Linux
Build
cargo build -p rmqttd --release
# Artifact: target/release/rmqttd (or rmqttd.exe)
Run
./target/release/rmqttd
./target/release/rmqttd -f /path/to/rmqtt.toml
./target/release/rmqttd --config /path/to/rmqtt.toml
./target/release/rmqttd --id 1
CLI arguments
Defined by rmqtt_conf::Options (via clap::Parser):
| Argument | Type | Description |
|---|---|---|
-f, --config |
Option<String> |
Config file path |
-V, --version |
bool |
Print version info |
--id |
Option<u64> |
Node ID |
--plugins-default-startups |
Option<Vec<String>> |
Override default plugin startups (repeatable) |
--node-grpc-addrs |
Option<Vec<NodeAddr>> |
Node gRPC addresses, format "1@127.0.0.1:5363" (repeatable) |
--raft-peer-addrs |
Option<Vec<NodeAddr>> |
Raft peer addresses, format "1@127.0.0.1:6003" (repeatable) |
--raft-leader-id |
Option<u64> |
Raft leader ID; default 0 (first node becomes leader) |
Configuration
Loaded by rmqtt_conf::Settings from the following paths (in priority order):
/etc/rmqtt/rmqtt.{toml,json,...}(optional)/etc/rmqtt.{toml,json,...}(optional)./rmqtt.{toml,json,...}(optional)-f/--configspecified file (optional)RMQTT_*environment variables
Docker
Three Dockerfiles for different architectures:
Dockerfile— defaultDockerfile.amd64— x86_64Dockerfile.aarch64— ARM64
docker build -t rmqttd .
Related crates
- rmqtt — Core MQTT Broker library
- rmqtt-conf — Configuration management
- rmqtt-plugins — Plugin collection
License
MIT OR Apache-2.0
Dependencies
~47–70MB
~1M SLoC