From 82042b3756b2f523407b383c9c841827d3743166 Mon Sep 17 00:00:00 2001 From: Cameron Norman Date: Sat, 17 Jan 2015 13:14:47 -0800 Subject: [PATCH 1/2] Add Upstart job to debian packaging, based on Ubuntu MySQL job --- debian/mariadb-server-10.1.mysql.upstart | 63 ++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 debian/mariadb-server-10.1.mysql.upstart diff --git a/debian/mariadb-server-10.1.mysql.upstart b/debian/mariadb-server-10.1.mysql.upstart new file mode 100644 index 0000000000000..1d08b31d15acd --- /dev/null +++ b/debian/mariadb-server-10.1.mysql.upstart @@ -0,0 +1,63 @@ +description "MariaDB 10.1 Server" +author "Mario Limonciello " + +start on runlevel [2345] +stop on starting rc RUNLEVEL=[016] + +respawn +respawn limit 2 5 + +env HOME=/etc/mysql +umask 007 + +# The default of 5 seconds is too low for mysql which needs to flush buffers +kill timeout 300 + +pre-start script + ## Fetch a particular option from mysql's invocation. + # Usage: void mysqld_get_param option + mysqld_get_param() { + /usr/sbin/mysqld --print-defaults \ + | tr " " "\n" \ + | grep -- "--$1" \ + | tail -n 1 \ + | cut -d= -f2 + } + + # priority can be overriden and "-s" adds output to stderr + ERR_LOGGER="logger -p daemon.err -t /etc/init/mysql.conf -i" + + #Sanity checks + [ -r $HOME/my.cnf ] + [ -d /var/run/mysqld ] || install -m 755 -o mysql -g root -d /var/run/mysqld + /lib/init/apparmor-profile-load usr.sbin.mysqld + + # check for diskspace shortage + datadir=`mysqld_get_param datadir` + BLOCKSIZE=`LC_ALL=C df --portability $datadir/. | tail -n 1 | awk '{print $4}'` + if [ $BLOCKSIZE -le 4096 ] ; then + echo "$0: ERROR: The partition with $datadir is too full!" >&2 + echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER + exit 1 + fi +end script + +exec /usr/sbin/mysqld + +post-start script + for i in `seq 1 30` ; do + /usr/bin/mysqladmin --defaults-file="${HOME}"/debian.cnf ping && { + exec "${HOME}"/debian-start + # should not reach this line + exit 2 + } + statusnow=`status` + if echo $statusnow | grep -q 'stop/' ; then + exit 0 + elif echo $statusnow | grep -q 'respawn/' ; then + exit 1 + fi + sleep 1 + done + exit 1 +end script From 451a04001fa3b7b771ba74b1fd60457e269fda72 Mon Sep 17 00:00:00 2001 From: Cameron Norman Date: Sat, 17 Jan 2015 13:17:04 -0800 Subject: [PATCH 2/2] Adjust stop on condition to not block shutdown --- debian/mariadb-server-10.1.mysql.upstart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/mariadb-server-10.1.mysql.upstart b/debian/mariadb-server-10.1.mysql.upstart index 1d08b31d15acd..8b94bee0da411 100644 --- a/debian/mariadb-server-10.1.mysql.upstart +++ b/debian/mariadb-server-10.1.mysql.upstart @@ -2,7 +2,7 @@ description "MariaDB 10.1 Server" author "Mario Limonciello " start on runlevel [2345] -stop on starting rc RUNLEVEL=[016] +stop on runlevel [016] respawn respawn limit 2 5