package/mosquitto: extend systemd integration
authorTitouan Christophe <titouan.christophe@railnova.eu>
Sat, 3 Aug 2019 09:38:57 +0000 (11:38 +0200)
committerPeter Korsgaard <peter@korsgaard.com>
Sat, 3 Aug 2019 11:14:48 +0000 (13:14 +0200)
Since version 1.5, mosquitto can be built with explicit support for
systemd. If enabled, libmosquitto will link against libsystemd: when
started, the mosquitto broker notifies systemd that it is ready (ie.
initialized and ready to accept connections), so that services that
depend on the mqtt broker can be started only at that point.

To enable this feature, the systemd service config file needs to change
to Type=notify. Upstream now provides such a file, so we can remove
ours.

Signed-off-by: Titouan Christophe <titouan.christophe@railnova.eu>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
package/mosquitto/mosquitto.mk
package/mosquitto/mosquitto.service [deleted file]

index eb39f0af6e963f5a026499403a3449ee2396d6cc..6de6fc804f09fd58b6ff3a5539bd72ea2791742a 100644 (file)
@@ -29,6 +29,11 @@ else
 MOSQUITTO_MAKE_OPTS += WITH_SHARED_LIBRARIES=yes
 endif
 
+ifeq ($(BR2_PACKAGE_SYSTEMD),y)
+MOSQUITTO_MAKE_OPTS += WITH_SYSTEMD=yes
+MOSQUITTO_DEPENDENCIES += systemd
+endif
+
 # adns uses getaddrinfo_a
 ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
 MOSQUITTO_MAKE_OPTS += WITH_ADNS=yes
@@ -102,7 +107,7 @@ define MOSQUITTO_INSTALL_INIT_SYSV
 endef
 
 define MOSQUITTO_INSTALL_INIT_SYSTEMD
-       $(INSTALL) -D -m 644 package/mosquitto/mosquitto.service \
+       $(INSTALL) -D -m 644 $(@D)/service/systemd/mosquitto.service.notify \
                $(TARGET_DIR)/usr/lib/systemd/system/mosquitto.service
        mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
        ln -fs ../../../../usr/lib/systemd/system/mosquitto.service \
diff --git a/package/mosquitto/mosquitto.service b/package/mosquitto/mosquitto.service
deleted file mode 100644 (file)
index 2d1939d..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=Mosquitto MQTT broker
-
-[Service]
-ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
-ExecReload=/bin/kill -HUP $MAINPID
-Restart=always
-
-[Install]
-WantedBy=multi-user.target