MaxScale/cmake/init_scripts.cmake
Markus Mäkelä 22a112e137
Remove redundant ExecStartPost command
The LimitCORE command already sets the process core size limit so the
post-start command appears to be useless. In addition, it appears to fail
from time to time due to pidof failing to return the process ID of
MaxScale right as it starts. This in turn results in an unexplainable
failure to start with no messages logged anywhere with the exception of
the following from systemctl:

[vagrant@maxscale build]$ sudo systemctl status maxscale
● maxscale.service - MariaDB MaxScale Database Proxy
   Loaded: loaded (/usr/lib/systemd/system/maxscale.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2020-12-16 21:16:55 CET; 26s ago
  Process: 304024 ExecStartPost=/bin/sh -c prlimit -p $(pidof maxscale) --core=unlimited (code=exited, status=1/FAILURE)
  Process: 304003 ExecStart=/usr/bin/maxscale (code=exited, status=0/SUCCESS)
  Process: 304001 ExecStartPre=/usr/bin/install -d /var/lib/maxscale -o maxscale -g maxscale (code=exited, status=0/SUCCESS)
  Process: 303999 ExecStartPre=/usr/bin/install -d /var/run/maxscale -o maxscale -g maxscale (code=exited, status=0/SUCCESS)
 Main PID: 304004 (code=exited, status=0/SUCCESS)
2020-12-16 22:35:38 +02:00

58 lines
3.0 KiB
CMake

# Check which init.d script to install
find_file(RPM_FNC functions PATHS /etc/rc.d/init.d)
find_file(DEB_FNC init-functions PATHS /lib/lsb)
find_file(SLES_FNC SuSE-release PATHS /etc)
if(EXISTS ${RPM_FNC})
set(USE_RPM TRUE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.")
elseif(EXISTS ${SLES_FNC})
set(USE_SLES TRUE CACHE BOOL "SLES11 has reduced /lib/lsb/init-functions and needs a special init-script")
elseif(EXISTS ${DEB_FNC})
set(USE_DEB TRUE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.")
else()
message(STATUS "Cannot find required init-functions in /lib/lsb/ or /etc/rc.d/init.d/, will not install init scripts.")
endif()
if(USE_DEB)
configure_file(${CMAKE_SOURCE_DIR}/etc/ubuntu/init.d/maxscale.in ${CMAKE_BINARY_DIR}/maxscale @ONLY)
elseif(USE_RPM)
configure_file(${CMAKE_SOURCE_DIR}/etc/init.d/maxscale.in ${CMAKE_BINARY_DIR}/maxscale @ONLY)
elseif(USE_SLES)
configure_file(${CMAKE_SOURCE_DIR}/etc/sles11/init.d/maxscale.in ${CMAKE_BINARY_DIR}/maxscale @ONLY)
else()
# Use a dummy file that tells the user that init scripts aren't supported on this platform
configure_file(${CMAKE_SOURCE_DIR}/etc/fallback/maxscale.in ${CMAKE_BINARY_DIR}/maxscale @ONLY)
endif()
configure_file(${CMAKE_SOURCE_DIR}/etc/maxscale.conf.in ${CMAKE_BINARY_DIR}/maxscale.conf @ONLY)
# The systemd service file
if (CMAKE_BUILD_TYPE MATCHES "(D|d)(E|e)(B|b)(U|u)(G|g)")
# Options enabled only in debug builds (a literal multi-line string)
set(SERVICE_FILE_DEBUG_OPTIONS "LimitCORE=infinity")
endif()
configure_file(${CMAKE_SOURCE_DIR}/etc/maxscale.service.in ${CMAKE_BINARY_DIR}/maxscale.service @ONLY)
if(PACKAGE)
message(STATUS "maxscale.conf will unpack to: /etc/ld.so.conf.d")
message(STATUS "startup scripts will unpack to to: /etc/init.d")
message(STATUS "systemd service files will unpack to to: /usr/lib/systemd/system")
message(STATUS "upstart files will unpack to: /etc/init/")
install_file(${CMAKE_BINARY_DIR}/maxscale core)
install_file(${CMAKE_BINARY_DIR}/maxscale.conf core)
install_file(${CMAKE_BINARY_DIR}/maxscale.service core)
install_file(${CMAKE_BINARY_DIR}/upstart/maxscale.conf core)
else()
install(PROGRAMS ${CMAKE_BINARY_DIR}/maxscale DESTINATION /etc/init.d COMPONENT core)
install(FILES ${CMAKE_BINARY_DIR}/maxscale.conf DESTINATION /etc/ld.so.conf.d COMPONENT core)
install(FILES ${CMAKE_BINARY_DIR}/maxscale.service DESTINATION /usr/lib/systemd/system COMPONENT core)
install(FILES ${CMAKE_BINARY_DIR}/upstart/maxscale.conf DESTINATION /etc/init/)
install(FILES ${CMAKE_SOURCE_DIR}/etc/logrotate.d/maxscale_logrotate DESTINATION /etc/logrotate.d/)
message(STATUS "Installing maxscale.conf to: /etc/ld.so.conf.d")
message(STATUS "Installing startup scripts to: /etc/init.d")
message(STATUS "Installing systemd service files to: /usr/lib/systemd/system")
message(STATUS "Installing upstart files to: /etc/init/")
message(STATUS "Installing logrotate config to: /etc/logrotate.d/maxscale_logrotate")
endif()