[MXS-1027] Add Upstart support (including respawn) for MaxScale Created: 2016-11-27  Updated: 2016-11-29  Resolved: 2016-11-29

Status: Closed
Project: MariaDB MaxScale
Component/s: StartupScripts
Affects Version/s: 2.0.1
Fix Version/s: 2.0.3

Type: Task Priority: Major
Reporter: Valerii Kravchuk Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None
Environment:

Linux with Upstart (RHEL/CentOS 6.x, Ubuntu 14.04, others)



 Description   

Please, add Upstart files for MaxScale service on systems that support upstart. It is better to use a native Upstart file (script) instead of old style SysV init scripts.

Upstart allows to respawn maxscale process after a crash or when it is deliberately killed. It seems respawn action in /etc/inittab does not work on systems with Upstart any more, and any other way to restart maxscale after crash automatically involves coding of additional scripts or using external additional HA frameworks.

Simple /etc/init/maxscale.conf may look like this (tested on CentOS 6.8 as a proof of concept):

[root@centos ~]# cat /etc/init/maxscale.conf
# MaxScale service
 
description "MaxScale"
 
start on stopped rc RUNLEVEL=[2345]
stop on starting rc runlevel [!2345]
 
respawn
respawn limit 2 5
 
expect fork
 
exec /usr/bin/maxscale --user=maxscale

But probably it misses pre-start script (based on what I see in the /etc/init.d/maxscale) and few more details that should be added and tested, and then maxscale.conf file included into the official packages for the systems using Upstart, with manual/KB pages changed/extended to cover initctl and Upstart usage in general.



 Comments   
Comment by markus makela [ 2016-11-28 ]

I took your suggestion and improved it a bit. The script installs the /var/run/maxscale directory and removes any limits on the number of open files. It also changes the user and group to maxscale making sure that the process gains no root privileges.

# 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 /home/markusjm/build/run/maxscale
 
# Change the user to maxscale:maxscale
setuid maxscale
setgid maxscale
 
# Start MaxScale
expect fork
exec /usr/bin/maxscale

Comment by markus makela [ 2016-11-29 ]

Added Upstart configuration.

Generated at Thu Feb 08 04:03:42 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.