Wait for daemon ends

Related: #1072958

Conflicts:
	community-mysql.spec
	mysql-scl-env-check.patch
This commit is contained in:
Honza Horak 2015-02-18 21:41:01 +01:00
parent 42a566e9d7
commit 9abc7519ce
4 changed files with 45 additions and 2 deletions

View File

@ -1,7 +1,7 @@
diff -rup mysql-5.6.19-orig/scripts/CMakeLists.txt mysql-5.6.19/scripts/CMakeLists.txt
--- mysql-5.6.19-orig/scripts/CMakeLists.txt 2014-07-22 10:07:12.053410263 +0200
+++ mysql-5.6.19/scripts/CMakeLists.txt 2014-07-22 10:10:44.102502369 +0200
@@ -381,6 +381,33 @@ ELSE()
@@ -381,6 +381,34 @@ ELSE()
ENDIF()
INSTALL_SCRIPT(${CMAKE_CURRENT_BINARY_DIR}/${file} COMPONENT ${${file}_COMPONENT})
ENDFOREACH()
@ -12,6 +12,7 @@ diff -rup mysql-5.6.19-orig/scripts/CMakeLists.txt mysql-5.6.19/scripts/CMakeLis
+ mysql.service
+ mysql-prepare-db-dir
+ mysql-wait-ready
+ mysql-wait-stop
+ mysql-check-socket
+ mysql-check-upgrade
+ mysql-scripts-common

View File

@ -100,6 +100,7 @@ Source13: mysql-wait-ready.sh
Source14: mysql-check-socket.sh
Source15: mysql-scripts-common.sh
Source16: mysql-check-upgrade.sh
Source17: mysql-wait-stop.sh
Source19: mysql.init.in
# To track rpmlint warnings
Source30: mysql-5.6.10-rpmlintrc
@ -440,7 +441,7 @@ add_test 'main.upgrade : unknown'
popd
cp %{SOURCE2} %{SOURCE3} %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} \
%{SOURCE14} %{SOURCE15} %{SOURCE16} %{SOURCE19} %{SOURCE31} scripts
%{SOURCE14} %{SOURCE15} %{SOURCE16} %{SOURCE17} %{SOURCE19} %{SOURCE31} scripts
%build
# fail quickly and obviously if user tries to build as root
@ -553,6 +554,7 @@ install -D -p -m 755 scripts/mysql.init %{buildroot}%{daemondir}/%{daemon_name}
# helper scripts for service starting
install -p -m 755 scripts/mysql-prepare-db-dir %{buildroot}%{_libexecdir}/mysql-prepare-db-dir
install -p -m 755 scripts/mysql-wait-ready %{buildroot}%{_libexecdir}/mysql-wait-ready
install -p -m 755 scripts/mysql-wait-stop %{buildroot}%{_libexecdir}/mysql-wait-stop
install -p -m 755 scripts/mysql-check-socket %{buildroot}%{_libexecdir}/mysql-check-socket
install -p -m 755 scripts/mysql-check-upgrade %{buildroot}%{_libexecdir}/mysql-check-upgrade
install -p -m 644 scripts/mysql-scripts-common %{buildroot}%{_libexecdir}/mysql-scripts-common
@ -894,6 +896,7 @@ fi
%{daemondir}/%{daemon_name}*
%{_libexecdir}/mysql-prepare-db-dir
%{_libexecdir}/mysql-wait-ready
%{_libexecdir}/mysql-wait-stop
%{_libexecdir}/mysql-check-socket
%{_libexecdir}/mysql-check-upgrade
%{_libexecdir}/mysql-scripts-common
@ -947,6 +950,8 @@ fi
Based on https://www.redhat.com/archives/sclorg/2015-February/msg00038.html
- Check permissions when starting service on RHEL-6
Resolves: #1194699
- Wait for daemon ends
Related: #1072958
* Mon Feb 23 2015 Honza Horak <hhorak@redhat.com> - 5.6.23-3
- Expand paths in perl scripts in mysql-test

36
mysql-wait-stop.sh Normal file
View File

@ -0,0 +1,36 @@
#!/bin/sh
source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common"
# This script waits for mysqld to be properly stopped
# (which can be many seconds in some large load).
# Running this as ExecStopPost is useful so that starting which is done
# as part of restart doesn't see the former process still running.
# Wait for the server to properly end the main server
ret=0
TIMEOUT=60
SECONDS=0
if ! [ -f "$pidfile" ]; then
exit 0
fi
MYSQLPID=`cat "$pidfile" 2>/dev/null`
if [ -z "$MYSQLPID" ] ; then
exit 2
fi
while /bin/true; do
# Check process still exists
if ! [ -d "/proc/${MYSQLPID}" ] ; then
break
fi
if [ $SECONDS -gt $TIMEOUT ] ; then
ret=3
break
fi
sleep 1
done
exit $ret

View File

@ -42,6 +42,7 @@ ExecStartPre=@libexecdir@/mysql-prepare-db-dir %n
ExecStart=@bindir@/mysqld_safe --basedir=@prefix@
ExecStartPost=@libexecdir@/mysql-wait-ready $MAINPID
ExecStartPost=@libexecdir@/mysql-check-upgrade
ExecStopPost=@libexecdir@/mysql-wait-stop
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300