-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEV-427/MDEV-5713 Add systemd script with notify functionality
- Loading branch information
1 parent
92271c7
commit 20c2ae3
Showing
23 changed files
with
551 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# 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 | ||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
INCLUDE(FindPkgConfig) | ||
# http://www.cmake.org/cmake/help/v3.0/module/FindPkgConfig.html | ||
|
||
MACRO(CHECK_SYSTEMD) | ||
IF(UNIX) | ||
SET(WITH_SYSTEMD "auto" CACHE STRING "Compile with systemd socket activation and notification") | ||
IF(WITH_SYSTEMD STREQUAL "yes" OR WITH_SYSTEMD STREQUAL "auto") | ||
IF(PKG_CONFIG_FOUND) | ||
IF(WITH_SYSTEMD STREQUAL "yes") | ||
pkg_check_modules(LIBSYSTEMD REQUIRED libsystemd) | ||
ELSE() | ||
pkg_check_modules(LIBSYSTEMD libsystemd) | ||
ENDIF() | ||
IF(HAVE_DLOPEN) | ||
SET(LIBSYSTEMD ${LIBSYSTEMD_LIBRARIES}) | ||
#SET(CMAKE_REQUIRED_FLAGS ${LIBSYSTEMD_CFLAGS}) | ||
SET(MYSQLD_LINK_FLAGS "${MYSQLD_LINK_FLAGS} ${LIBSYSTEMD_LDFLAGS}") | ||
ELSE() | ||
SET(LIBSYSTEMD ${LIBSYSTEMD_STATIC_LIBRARIES}) | ||
#SET(CMAKE_REQUIRED_FLAGS ${LIBSYSTEMD_STATIC_CFLAGS}) | ||
SET(MYSQLD_LINK_FLAGS "${MYSQLD_LINK_FLAGS} ${LIBSYSTEMD_STATIC_LDFLAGS}") | ||
ENDIF() | ||
ELSE() | ||
SET(LIBSYSTEMD systemd) | ||
ENDIF() | ||
SET(CMAKE_REQUIRED_LIBRARIES ${LIBSYSTEMD}) | ||
CHECK_C_SOURCE_COMPILES( | ||
" | ||
#include <systemd/sd-daemon.h> | ||
int main() | ||
{ | ||
sd_listen_fds(0); | ||
}" | ||
HAVE_SYSTEMD) | ||
CHECK_INCLUDE_FILES(systemd/sd-daemon.h HAVE_SYSTEMD_SD_DAEMON_H) | ||
CHECK_FUNCTION_EXISTS(sd_listen_fds HAVE_SYSTEMD_SD_LISTEN_FDS) | ||
CHECK_FUNCTION_EXISTS(sd_notify HAVE_SYSTEMD_SD_NOTIFY) | ||
CHECK_FUNCTION_EXISTS(sd_notifyf HAVE_SYSTEMD_SD_NOTIFYF) | ||
IF(HAVE_SYSTEMD AND HAVE_SYSTEMD_SD_DAEMON_H AND HAVE_SYSTEMD_SD_LISTEN_FDS | ||
AND HAVE_SYSTEMD_SD_NOTIFY AND HAVE_SYSTEMD_SD_NOTIFYF) | ||
ADD_DEFINITIONS(-DHAVE_SYSTEMD) | ||
# should be from pkg-config --variable=systemdsystemconfdir systemd | ||
# Missing CMake macro: http://public.kitware.com/Bug/view.php?id=15634 | ||
SET(SYSTEMD_SYSTEM_CONFDIR /etc/systemd/system) | ||
# should be from pkg-config --variable=systemdsystemunitdir systemd | ||
SET(SYSTEMD_SYSTEM_UNITDIR /usr/lib/systemd/system/) | ||
MESSAGE(STATUS "Systemd features enabled") | ||
ELSE() | ||
UNSET(LIBSYSTEMD) | ||
UNSET(HAVE_SYSTEMD_SD_DAEMON_H) | ||
UNSET(HAVE_SYSTEMD_SD_LISTEN_FDS) | ||
UNSET(HAVE_SYSTEMD_SD_NOTIFY) | ||
UNSET(HAVE_SYSTEMD_SD_NOTIFYF) | ||
MESSAGE(STATUS "Systemd features not enabled") | ||
IF(WITH_SYSTEMD STREQUAL "yes") | ||
MESSAGE(FATAL_ERROR "Requested WITH_SYSTEMD=YES however no dependencies installed/found") | ||
ENDIF() | ||
ENDIF() | ||
ENDIF() | ||
ENDIF() | ||
ENDMACRO() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
#ifndef MY_SYSTEMD_INCLUDED | ||
#define MY_SYSTEMD_INCLUDED | ||
|
||
#if defined(HAVE_SYSTEMD) && !defined(EMBEDDED_LIBRARY) | ||
#include <systemd/sd-daemon.h> | ||
|
||
#else | ||
|
||
|
||
|
||
#define sd_notify(X, Y) | ||
#define sd_notifyf(E, F, ...) | ||
|
||
#endif | ||
|
||
#endif /* MY_SYSTEMD_INCLUDED */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/bash | ||
# 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 | ||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
# PURPOSE: | ||
# | ||
# Used to generate a mariadb.service file based on the curent mysql/maridb settings | ||
# | ||
# This is to assist distro maintainers in migrating to systemd service definations from | ||
# a user mysqld_safe settings in the my.cnf files. | ||
# | ||
# Redirect output to user directory like /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf | ||
|
||
tz_old=$TZ | ||
|
||
get_params() | ||
{ | ||
# does a return so needs to be wrapped in a function | ||
# . /usr/bin/mysqld_safe --simulate | ||
. scripts/mysqld_safe --simulate | ||
} | ||
|
||
get_params | ||
|
||
echo "# converted using $0" | ||
echo "#" | ||
echo | ||
|
||
echo '[Service]' | ||
|
||
echo | ||
|
||
|
||
if [[ ( "$user" != "root" && "$user" != "mysql" ) || "${SET_USER}" == 1 ]]; then | ||
echo User=$user | ||
fi | ||
|
||
|
||
[ -n "${open_files}" ] && echo LimitNOFILE=$open_files | ||
[ -n "${core_file_size}" ] && echo LimitCore=$core_file_size | ||
[[ "${niceness}" -gt 0 ]] && echo Nice=$niceness | ||
[ "${TZ}" != "${tz_old}" ] && echo Environment=\"TZ=${TZ}\" | ||
|
||
if [ -n "$mysqld_ld_preload" ]; then | ||
new_text="$mysqld_ld_preload" | ||
[ -n "$LD_PRELOAD" ] && new_text="$new_text $LD_PRELOAD" | ||
echo Environment=\"LD_PRELOAD=`shell_quote_string "$new_text"`\" | ||
fi | ||
|
||
if [ -n "$mysqld_ld_library_path" ]; then | ||
new_text="$mysqld_ld_library_path" | ||
[ -n "$LD_LIBRARY_PATH" ] && new_text="$new_text:$LD_LIBRARY_PATH" | ||
echo Environment=\"LD_LIBRARY_PATH=`shell_quote_string "$new_text"`\" | ||
fi | ||
|
||
if [[ $want_syslog -eq 1 ]]; then | ||
echo StandardError=syslog | ||
echo SyslogFacility=daemon | ||
echo SyslogLevel=error | ||
echo SyslogLevelPrefix=${syslog_tag_mysqld} | ||
fi | ||
|
||
if [[ "${flush_caches}" -gt 0 ]]; then | ||
echo ExecStartPre=sync | ||
echo ExecStartPre=sysctl -q -w vm.drop_caches=3 | ||
fi | ||
|
||
if [[ "${numa_interleave}" -gt 0 ]]; then | ||
echo | ||
echo ExecStart=numactl --interleave=all ${cmd} '${OPTIONS}' | ||
echo | ||
fi | ||
|
||
[ -n "${CRASH_SCRIPT}" ] && echo FailureAction=${CRASH_SCRIPT} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.