[471053] Add systemd support and services.
Add possibility to notify systemd that service is fully started. Also add reference service files. Change-Id: Ib4e39c8406ab6c15e1b88f197ae8f91c3e402023 Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=471053 Signed-off-by: Tomas Novotny <novotny@rehivetech.com>
This commit is contained in:
parent
f3e216ee82
commit
29731b5e46
@ -17,6 +17,7 @@ Broker:
|
|||||||
- Add use_subject_as_username option for certificate based client
|
- Add use_subject_as_username option for certificate based client
|
||||||
authentication to use the entire certificate subject as a username, rather
|
authentication to use the entire certificate subject as a username, rather
|
||||||
than just the CN. Closes #469467.
|
than just the CN. Closes #469467.
|
||||||
|
- Add systemd startup notification and services. Closes #471053.
|
||||||
|
|
||||||
Client library:
|
Client library:
|
||||||
- Outgoing messages with QoS>1 are no longer retried after a timeout period.
|
- Outgoing messages with QoS>1 are no longer retried after a timeout period.
|
||||||
|
@ -4,6 +4,7 @@ The following packages are required for mosquitto:
|
|||||||
* openssl (version 1.0.0 or greater if TLS-PSK support is needed, can be disabled)
|
* openssl (version 1.0.0 or greater if TLS-PSK support is needed, can be disabled)
|
||||||
* c-ares (for DNS-SRV support, can be disabled)
|
* c-ares (for DNS-SRV support, can be disabled)
|
||||||
* libuuid (from e2fsprogs, can be disabled)
|
* libuuid (from e2fsprogs, can be disabled)
|
||||||
|
* libsystemd (optional, disabled by default)
|
||||||
* On Windows, the Redhat pthreads library is required if threading support is
|
* On Windows, the Redhat pthreads library is required if threading support is
|
||||||
to be included.
|
to be included.
|
||||||
|
|
||||||
|
@ -57,6 +57,10 @@ WITH_MEMORY_TRACKING:=yes
|
|||||||
# information about the broker state.
|
# information about the broker state.
|
||||||
WITH_SYS_TREE:=yes
|
WITH_SYS_TREE:=yes
|
||||||
|
|
||||||
|
# Build with systemd support. If enabled, mosquitto will notify systemd after
|
||||||
|
# initialization. See README in service/systemd/ for more information.
|
||||||
|
WITH_SYSTEMD:=no
|
||||||
|
|
||||||
# Build with SRV lookup support.
|
# Build with SRV lookup support.
|
||||||
WITH_SRV:=yes
|
WITH_SRV:=yes
|
||||||
|
|
||||||
@ -215,6 +219,11 @@ ifeq ($(WITH_SYS_TREE),yes)
|
|||||||
BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_SYS_TREE
|
BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_SYS_TREE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(WITH_SYSTEMD),yes)
|
||||||
|
BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_SYSTEMD
|
||||||
|
BROKER_LIBS:=$(BROKER_LIBS) -lsystemd
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(WITH_SRV),yes)
|
ifeq ($(WITH_SRV),yes)
|
||||||
LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_SRV
|
LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_SRV
|
||||||
LIB_LIBS:=$(LIB_LIBS) -lcares
|
LIB_LIBS:=$(LIB_LIBS) -lcares
|
||||||
|
8
service/systemd/README
Normal file
8
service/systemd/README
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Select appropriate systemd service based on your compile settings. If you
|
||||||
|
enabled WITH_SYSTEMD, use mosquitto.service.notify, otherwise use
|
||||||
|
mosquitto.service.simple. The service must be renamed to mosquitto.service
|
||||||
|
before usage.
|
||||||
|
|
||||||
|
With WITH_SYSTEMD mosquitto will notify a complete startup after
|
||||||
|
initialization. This means that follow-up units can be started after full
|
||||||
|
initialization of mosquitto (i.e. sockets are opened).
|
11
service/systemd/mosquitto.service.notify
Normal file
11
service/systemd/mosquitto.service.notify
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Mosquitto MQTT v3.1/v3.1.1 Broker
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=notify
|
||||||
|
NotifyAccess=main
|
||||||
|
ExecStart=/usr/sbin/mosquitto
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
9
service/systemd/mosquitto.service.simple
Normal file
9
service/systemd/mosquitto.service.simple
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Mosquitto MQTT v3.1/v3.1.1 Broker
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/sbin/mosquitto
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@ -67,6 +67,16 @@ if (${WITH_SYS_TREE} STREQUAL ON)
|
|||||||
add_definitions("-DWITH_SYS_TREE")
|
add_definitions("-DWITH_SYS_TREE")
|
||||||
endif (${WITH_SYS_TREE} STREQUAL ON)
|
endif (${WITH_SYS_TREE} STREQUAL ON)
|
||||||
|
|
||||||
|
if (CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||||
|
option(WITH_SYSTEMD
|
||||||
|
"Include systemd support?" OFF)
|
||||||
|
if (${WITH_SYSTEMD} STREQUAL ON)
|
||||||
|
add_definitions("-DWITH_SYSTEMD")
|
||||||
|
find_library(SYSTEMD_LIBRARY systemd)
|
||||||
|
set (MOSQ_LIBS ${MOSQ_LIBS} ${SYSTEMD_LIBRARY})
|
||||||
|
endif (${WITH_SYSTEMD} STREQUAL ON)
|
||||||
|
endif (CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||||
|
|
||||||
option(WITH_WEBSOCKETS
|
option(WITH_WEBSOCKETS
|
||||||
"Include websockets support?" OFF)
|
"Include websockets support?" OFF)
|
||||||
if (${WITH_WEBSOCKETS} STREQUAL ON)
|
if (${WITH_WEBSOCKETS} STREQUAL ON)
|
||||||
|
@ -39,6 +39,9 @@ Contributors:
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifdef WITH_SYSTEMD
|
||||||
|
# include <systemd/sd-daemon.h>
|
||||||
|
#endif
|
||||||
#ifdef WITH_WRAP
|
#ifdef WITH_WRAP
|
||||||
#include <tcpd.h>
|
#include <tcpd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -362,6 +365,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_SYSTEMD
|
||||||
|
sd_notify(0, "READY=1");
|
||||||
|
#endif
|
||||||
|
|
||||||
run = 1;
|
run = 1;
|
||||||
rc = mosquitto_main_loop(&int_db, listensock, listensock_count, listener_max);
|
rc = mosquitto_main_loop(&int_db, listensock, listensock_count, listener_max);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user