2015-09-17 14:16:19 +02:00
|
|
|
# Copyright (c) 2015, Daniel Black. All rights reserved.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; version 2 of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2019-05-11 21:19:05 +02:00
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
|
2015-09-17 14:16:19 +02:00
|
|
|
|
|
|
|
MACRO(CHECK_SYSTEMD)
|
|
|
|
IF(UNIX)
|
2017-09-21 18:05:39 +02:00
|
|
|
INCLUDE(FindPkgConfig)
|
|
|
|
# http://www.cmake.org/cmake/help/v3.0/module/FindPkgConfig.html
|
2022-01-27 15:07:02 +01:00
|
|
|
SET(WITH_SYSTEMD "auto" CACHE STRING "Enable systemd scripts and notification support. Allowed values yes/no/auto.")
|
2015-09-17 14:16:19 +02:00
|
|
|
IF(WITH_SYSTEMD STREQUAL "yes" OR WITH_SYSTEMD STREQUAL "auto")
|
|
|
|
IF(PKG_CONFIG_FOUND)
|
2018-07-05 14:23:23 +02:00
|
|
|
IF (NOT DEFINED LIBSYSTEMD_FOUND)
|
|
|
|
IF(WITH_SYSTEMD STREQUAL "yes")
|
|
|
|
pkg_search_module(LIBSYSTEMD REQUIRED libsystemd libsystemd-daemon)
|
|
|
|
ELSE()
|
|
|
|
pkg_search_module(LIBSYSTEMD libsystemd libsystemd-daemon)
|
|
|
|
ENDIF()
|
2015-09-17 14:16:19 +02:00
|
|
|
ENDIF()
|
|
|
|
IF(HAVE_DLOPEN)
|
2019-06-18 14:19:49 +02:00
|
|
|
SET(LIBSYSTEMD ${LIBSYSTEMD_LDFLAGS} ${LIBSYSTEMD_LIBRARIES})
|
2015-09-17 14:16:19 +02:00
|
|
|
ELSE()
|
2019-06-18 14:19:49 +02:00
|
|
|
SET(LIBSYSTEMD ${LIBSYSTEMD_STATIC_LDFLAGS} ${LIBSYSTEMD_STATIC_LIBRARIES})
|
2015-09-17 14:16:19 +02:00
|
|
|
ENDIF()
|
|
|
|
ELSE()
|
|
|
|
SET(LIBSYSTEMD systemd)
|
|
|
|
ENDIF()
|
|
|
|
SET(CMAKE_REQUIRED_LIBRARIES ${LIBSYSTEMD})
|
2019-03-16 19:44:40 +01:00
|
|
|
CHECK_LIBRARY_EXISTS(systemd sd_listen_fds "" HAVE_SYSTEMD_SD_LISTEN_FDS)
|
MDEV-5536: add systemd socket activation
Systemd has a socket activation feature where a mariadb.socket
definition defines the sockets to listen to, and passes those
file descriptors directly to mariadbd to use when a connection
occurs.
The new functionality is utilized when starting as follows:
systemctl start mariadb.socket
The mariadb.socket definition only needs to contain the network
information, ListenStream= directives, the mariadb.service
definition is still used for service instigation.
When mariadbd is started in this way, the socket, port, bind-address
backlog are all assumed to be self contained in the mariadb.socket
definition and as such the mariadb settings and command line
arguments of these network settings are ignored.
See man systemd.socket for how to limit this to specific ports.
Extra ports, those specified with extra_port in socket activation
mode, are those with a FileDescriptorName=extra. These need
to be in a separate service name like mariadb-extra.socket and
these require a Service={mariadb.service} directive to map to the
original service. Extra ports need systemd v227 or greater
(not RHEL/Centos7 - v219) when FileDescriptorName= was added,
otherwise the extra ports are treated like ordinary ports.
The number of sockets isn't limited when using systemd socket activation
(except by operating system limits on file descriptors and a minimal
amount of memory used per file descriptor). The systemd sockets passed
can include any ownership or permissions, including those the
mariadbd process wouldn't normally have the permission to create.
This implementation is compatible with mariadb.service definitions.
Those services started with:
systemctl start mariadb.service
does actually start the mariadb.service and used all the my.cnf
settings of sockets and ports like it previously did.
2015-03-11 21:26:04 +01:00
|
|
|
CHECK_LIBRARY_EXISTS(systemd sd_listen_fds_with_names "" HAVE_SYSTEMD_SD_LISTEN_FDS_WITH_NAMES)
|
2015-09-17 14:16:19 +02:00
|
|
|
CHECK_INCLUDE_FILES(systemd/sd-daemon.h HAVE_SYSTEMD_SD_DAEMON_H)
|
|
|
|
CHECK_FUNCTION_EXISTS(sd_notify HAVE_SYSTEMD_SD_NOTIFY)
|
|
|
|
CHECK_FUNCTION_EXISTS(sd_notifyf HAVE_SYSTEMD_SD_NOTIFYF)
|
2015-09-28 13:08:09 +02:00
|
|
|
SET(CMAKE_REQUIRED_LIBRARIES)
|
2019-03-16 19:44:40 +01:00
|
|
|
IF(HAVE_SYSTEMD_SD_DAEMON_H AND HAVE_SYSTEMD_SD_LISTEN_FDS
|
2015-09-17 14:16:19 +02:00
|
|
|
AND HAVE_SYSTEMD_SD_NOTIFY AND HAVE_SYSTEMD_SD_NOTIFYF)
|
2019-03-16 19:44:40 +01:00
|
|
|
SET(HAVE_SYSTEMD TRUE)
|
2022-11-28 19:21:03 +01:00
|
|
|
SET(SYSTEMD_SCRIPTS mariadb-service-convert)
|
|
|
|
IF(WITH_WSREP)
|
|
|
|
SET(SYSTEMD_SCRIPTS ${SYSTEMD_SCRIPTS} galera_new_cluster galera_recovery)
|
|
|
|
ENDIF()
|
2015-09-28 13:08:09 +02:00
|
|
|
IF(DEB)
|
2015-10-14 07:46:31 +02:00
|
|
|
SET(SYSTEMD_EXECSTARTPRE "ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld")
|
2015-09-28 13:08:09 +02:00
|
|
|
SET(SYSTEMD_EXECSTARTPOST "ExecStartPost=/etc/mysql/debian-start")
|
|
|
|
ENDIF()
|
2021-03-20 15:23:47 +01:00
|
|
|
IF(URING_FOUND)
|
2021-03-15 10:30:17 +01:00
|
|
|
SET(SYSTEMD_LIMIT "# For liburing and io_uring_setup()
|
|
|
|
LimitMEMLOCK=524288")
|
|
|
|
ENDIF()
|
2022-02-03 17:01:31 +01:00
|
|
|
|
2021-11-16 11:53:51 +01:00
|
|
|
IF(NOT DEB AND NOT RPM)
|
|
|
|
SET(SYSTEMD_READWRITEPATH "# Database dir: '${MYSQL_DATADIR}' should be writable even
|
|
|
|
# ProtectSystem=full prevents it
|
|
|
|
ReadWritePaths=-${MYSQL_DATADIR}\n")
|
|
|
|
ENDIF()
|
|
|
|
|
2015-11-22 07:20:15 +01:00
|
|
|
MESSAGE_ONCE(systemd "Systemd features enabled")
|
2015-09-17 14:16:19 +02:00
|
|
|
ELSE()
|
|
|
|
UNSET(LIBSYSTEMD)
|
2015-09-28 13:08:09 +02:00
|
|
|
UNSET(HAVE_SYSTEMD)
|
2015-09-17 14:16:19 +02:00
|
|
|
UNSET(HAVE_SYSTEMD_SD_DAEMON_H)
|
|
|
|
UNSET(HAVE_SYSTEMD_SD_LISTEN_FDS)
|
|
|
|
UNSET(HAVE_SYSTEMD_SD_NOTIFY)
|
|
|
|
UNSET(HAVE_SYSTEMD_SD_NOTIFYF)
|
2015-11-22 07:20:15 +01:00
|
|
|
MESSAGE_ONCE(systemd "Systemd features not enabled")
|
2015-09-17 14:16:19 +02:00
|
|
|
IF(WITH_SYSTEMD STREQUAL "yes")
|
2017-07-14 16:14:22 +02:00
|
|
|
MESSAGE(FATAL_ERROR "Requested WITH_SYSTEMD=yes however no dependencies installed/found")
|
2015-09-17 14:16:19 +02:00
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
2017-07-14 16:14:22 +02:00
|
|
|
ELSEIF(NOT WITH_SYSTEMD STREQUAL "no")
|
|
|
|
MESSAGE(FATAL_ERROR "Invalid value for WITH_SYSTEMD. Must be 'yes', 'no', or 'auto'.")
|
2015-09-17 14:16:19 +02:00
|
|
|
ENDIF()
|
2017-08-09 21:39:18 +02:00
|
|
|
ADD_FEATURE_INFO(SYSTEMD LIBSYSTEMD "Systemd scripts and notification support")
|
2015-09-17 14:16:19 +02:00
|
|
|
ENDIF()
|
|
|
|
ENDMACRO()
|