Running under systemd
LavinMQ supports SystemD socket activation and can be managed as a SystemD service.
Socket Activation
SystemD socket activation allows SystemD to listen on the configured ports and pass the sockets to LavinMQ on startup. This enables:
- New connections are queued by SystemD while LavinMQ restarts
- Lazy startup (LavinMQ starts only when a connection arrives)
- Privilege separation (SystemD binds privileged ports, LavinMQ runs unprivileged)
Socket Names
| Config Key | Default | Description |
|---|---|---|
amqp_systemd_socket_name |
lavinmq-amqp.socket |
AMQP socket unit name |
http_systemd_socket_name |
lavinmq-http.socket |
HTTP socket unit name |
Setup
Create socket unit files (e.g., /etc/systemd/system/lavinmq-amqp.socket):
[Socket]
ListenStream=5672
[Install]
WantedBy=sockets.target
And a service unit (e.g., /etc/systemd/system/lavinmq.service):
[Unit]
Description=LavinMQ
After=network.target
[Service]
Type=notify
ExecStart=/usr/bin/lavinmq --config /etc/lavinmq/lavinmq.ini
Restart=on-failure
User=lavinmq
Group=lavinmq
[Install]
WantedBy=multi-user.target
PID File
LavinMQ can write its PID to a file on startup for process management:
[main]
pidfile = /var/run/lavinmq/lavinmq.pid
The PID file is removed on graceful shutdown.
Graceful Restart
Send SIGTERM to gracefully shut down LavinMQ. SystemD will restart it automatically if Restart=on-failure is set. With socket activation, new connections are queued by SystemD during the restart window.
LavinMQ uses sd_notify to signal readiness and shutdown to SystemD. Type=notify in the service unit lets SystemD track the lifecycle correctly.
Ready to take the next steps?
Managed LavinMQ instance via CloudAMQP
LavinMQ has been built with performance and ease of use in mind - we've benchmarked a throughput of about 1,000,000 messages/sec . You can try LavinMQ without any installation hassle by creating a free instance on CloudAMQP. Signing up is a breeze.
Get started with CloudAMQP ->Help and feedback
We welcome your feedback and are eager to address any questions you may have about this piece or using LavinMQ. Join our Slack channel to connect with us directly. You can also find LavinMQ on GitHub.