By cpt
I am trying to configure Mosquitto broker to autostart on Ubuntu 16.04, but I cannot get systemd set up correctly and keep getting errors. I’ve tried numerous things, with my latest being:
[Unit]
Description=Insite MQTT Broker
[Service]
ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Restart=always
[Install]
WantedBy=multi-user.target
When I check systemctl status, I get this:
mosquitto.service - MQTT Broker
Loaded: loaded (/etc/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
Active: inactive (dead) (Result: exit-code) since Mon 2016-08-22 18:23:13 UTC; 20h ago
Main PID: 2696 (code=exited, status=200/CHDIR)
Aug 22 18:23:13 main-server-1 systemd[1]: mosquitto.service: Service hold-off time over, scheduling
Aug 22 18:23:13 main-server-1 systemd[1]: Stopped MQTT Broker.
Aug 22 18:23:13 main-server-1 systemd[1]: mosquitto.service: Start request repeated too quickly.
Aug 22 18:23:13 main-server-1 systemd[1]: Failed to start MQTT Broker.
The only tutorials I’ve found for Mosquitto use startup.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I was able to find another example of a systemd service file for a Mosquito broker here. As this shows a known working configuration, I’d recommend adjusting yours to match and making any minor adjustments necessary.
Try adding After=network.target to the [Unit] section?
Also make sure the path to mosquitto is correct (which mosquitto should return /usr/sbin/mosquitto)
The service file seems OK otherwise
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.