MXS-1027: Add Upstart config file

Various older systems use Upstart to control services. MaxScale should
provide both init.d scripts and Upstart configurations for systems that
don't support systemd.
This commit is contained in:
Markus Makela 2016-11-28 10:45:34 +02:00
parent cb93db4647
commit 2fe13719bc
3 changed files with 36 additions and 0 deletions

View File

@ -169,6 +169,7 @@ configure_file(${CMAKE_SOURCE_DIR}/server/include/adminusers.h.in ${CMAKE_BINARY
configure_file(${CMAKE_SOURCE_DIR}/server/test/maxscale_test.h.in ${CMAKE_BINARY_DIR}/server/include/maxscale_test.h @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/etc/postinst.in ${CMAKE_BINARY_DIR}/postinst @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/etc/postrm.in ${CMAKE_BINARY_DIR}/postrm @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/etc/upstart/maxscale.conf.in ${CMAKE_BINARY_DIR}/upstart/maxscale.conf @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/server/test/maxscale_test.cnf ${CMAKE_BINARY_DIR}/maxscale.cnf @ONLY)
set(FLAGS "-Wall -Wno-unused-variable -Wno-unused-function -Werror -fPIC" CACHE STRING "Compilation flags")
@ -284,16 +285,20 @@ if(WITH_SCRIPTS)
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(PROGRAMS ${CMAKE_BINARY_DIR}/maxscale DESTINATION ${MAXSCALE_SHAREDIR} )
install(FILES ${CMAKE_BINARY_DIR}/maxscale.conf DESTINATION ${MAXSCALE_SHAREDIR})
install(FILES ${CMAKE_BINARY_DIR}/maxscale.service DESTINATION ${MAXSCALE_SHAREDIR})
install(FILES ${CMAKE_BINARY_DIR}/upstart/maxscale.conf DESTINATION ${MAXSCALE_SHAREDIR}/upstart/)
else()
install(PROGRAMS ${CMAKE_BINARY_DIR}/maxscale DESTINATION /etc/init.d)
install(FILES ${CMAKE_BINARY_DIR}/maxscale.conf DESTINATION /etc/ld.so.conf.d)
install(FILES ${CMAKE_BINARY_DIR}/maxscale.service DESTINATION /usr/lib/systemd/system)
install(FILES ${CMAKE_BINARY_DIR}/upstart/maxscale.conf DESTINATION /etc/init/)
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/")
endif()
endif()

View File

@ -50,6 +50,11 @@ then
systemctl daemon-reload
fi
else
if [ -d "/etc/init/" ]
then
cp @CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@/upstart/maxscale.conf /etc/init/
fi
# If systemd is not present, use init.d scripts
if [ -f "@CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@/maxscale" ]
then

View File

@ -0,0 +1,26 @@
# MaxScale service
description "MariaDB MaxScale"
start on stopped rc RUNLEVEL=[2345]
stop on starting rc runlevel [!2345]
# Respawn the process on abnormal exits
respawn
# Uncomment this to limit respawns to two every five minutes
# respawn limit 2 5
# Unlimited open files
limit nofile unlimited unlimited
# Make sure /var/run/maxscale exists
pre-start exec /usr/bin/install -d -o maxscale -g maxscale @MAXSCALE_VARDIR@/run/maxscale
# Change the user to maxscale:maxscale
setuid maxscale
setgid maxscale
# Start MaxScale
expect fork
exec /usr/bin/maxscale