2015-09-28 13:08:09 +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 Street, Fifth Floor, Boston, MA 02110-1335 USA
|
2015-09-28 13:08:09 +02:00
|
|
|
*/
|
|
|
|
|
2015-09-17 14:16:19 +02:00
|
|
|
|
2017-11-30 03:37:59 +01:00
|
|
|
#ifndef MY_SERVICE_MANAGER_INCLUDED
|
|
|
|
#define MY_SERVICE_MANAGER_INCLUDED
|
2015-09-17 14:16:19 +02:00
|
|
|
|
|
|
|
#if defined(HAVE_SYSTEMD) && !defined(EMBEDDED_LIBRARY)
|
2015-09-28 13:08:09 +02:00
|
|
|
/*
|
|
|
|
sd-daemon.h may include inttypes.h. Explicitly request format macros before
|
|
|
|
the first inclusion of inttypes.h.
|
|
|
|
*/
|
2018-09-14 08:47:22 +02:00
|
|
|
#if !defined(__STDC_FORMAT_MACROS)
|
2015-09-28 13:08:09 +02:00
|
|
|
#define __STDC_FORMAT_MACROS
|
2018-09-14 08:47:22 +02:00
|
|
|
#endif // !defined(__STDC_FORMAT_MACROS)
|
2015-09-17 14:16:19 +02:00
|
|
|
#include <systemd/sd-daemon.h>
|
2017-11-30 03:37:59 +01:00
|
|
|
/** INTERVAL in seconds followed by printf style status */
|
|
|
|
#define service_manager_extend_timeout(INTERVAL, FMTSTR, ...) \
|
|
|
|
sd_notifyf(0, "STATUS=" FMTSTR "\nEXTEND_TIMEOUT_USEC=%u\n", ##__VA_ARGS__, INTERVAL * 1000000)
|
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
|
|
|
/* sd_listen_fds_with_names added v227 however RHEL/Centos7 has v219, fallback to sd_listen_fds */
|
|
|
|
#ifndef HAVE_SYSTEMD_SD_LISTEN_FDS_WITH_NAMES
|
|
|
|
#define sd_listen_fds_with_names(FD, NAMES) sd_listen_fds(FD)
|
|
|
|
#endif
|
2017-11-30 03:37:59 +01:00
|
|
|
|
2015-09-17 14:16:19 +02:00
|
|
|
#else
|
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
|
|
|
#define sd_listen_fds_with_names(FD, NAMES) (0)
|
|
|
|
#define sd_is_socket_unix(FD, TYPE, LISTENING, PATH, SIZE) (0)
|
|
|
|
#define sd_is_socket_inet(FD, FAMILY, TYPE, LISTENING, PORT) (0)
|
|
|
|
#define SD_LISTEN_FDS_START (0)
|
2015-09-17 14:16:19 +02:00
|
|
|
#define sd_notify(X, Y)
|
|
|
|
#define sd_notifyf(E, F, ...)
|
2022-04-08 18:54:26 +02:00
|
|
|
#ifdef _WIN32
|
|
|
|
#define service_manager_extend_timeout(I, F, ...) \
|
|
|
|
mysqld_win_extend_service_timeout(I)
|
|
|
|
#else
|
|
|
|
#define service_manager_extend_timeout(I, FMTSTR, ...)
|
|
|
|
#endif
|
2015-09-17 14:16:19 +02:00
|
|
|
#endif
|
|
|
|
|
2017-11-30 03:37:59 +01:00
|
|
|
#endif /* MY_SERVICE_MANAGER_INCLUDED */
|