mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
Bug #4858: mysql_safe logs to syslog instead of stderr
mysqld_safe.sh: Overhaul the logging design, to allow logging mysqld messages to syslog. Add --syslog and --skip-syslog arguments for mysqld_safe. scripts/mysqld_safe.sh: Overhaul the logging design, to allow logging mysqld messages to syslog. Add two new options: --syslog and --skip-syslog. --syslog is the default, unless --log-error is also specified. If --log-error is specified (for mysqld_safe, mysqld, server, etc. - any group which mysqld_safe checks for arguments), then syslog is turned off. This is because mysqld will get the --log-error argument and log to a file anyways, which will be confusing to the user. If the user requests both --syslog and --log-error, a warning is printed (to mysqld_safe's stderr and to syslog), and we then behave as if --skip-syslog had been specified. Also, logging messages have been normalized somewhat: mysqld_safe now always prefixes messages with '<TIMESTAMP> mysqld_safe '. All messages go to the the console (stdout or stderr, depending on if it's a notice or an error) and to (the error log OR syslog). Also, a few cleanups while I'm here.
This commit is contained in:
parent
1fe6d1511a
commit
aca2b28e7e
1 changed files with 153 additions and 102 deletions
|
@ -2,16 +2,23 @@
|
||||||
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
|
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
|
||||||
# This file is public domain and comes with NO WARRANTY of any kind
|
# This file is public domain and comes with NO WARRANTY of any kind
|
||||||
#
|
#
|
||||||
# scripts to start the MySQL daemon and restart it if it dies unexpectedly
|
# Script to start the MySQL daemon and restart it if it dies unexpectedly
|
||||||
#
|
#
|
||||||
# This should be executed in the MySQL base directory if you are using a
|
# This should be executed in the MySQL base directory if you are using a
|
||||||
# binary installation that has other paths than you are using.
|
# binary installation that is not installed in its compile-time default
|
||||||
|
# location
|
||||||
#
|
#
|
||||||
# mysql.server works by first doing a cd to the base directory and from there
|
# mysql.server works by first doing a cd to the base directory and from there
|
||||||
# executing mysqld_safe
|
# executing mysqld_safe
|
||||||
|
|
||||||
KILL_MYSQLD=1;
|
KILL_MYSQLD=1;
|
||||||
MYSQLD=
|
MYSQLD=
|
||||||
|
niceness=0
|
||||||
|
# Default on, unless --log-err is specified (and before options are parsed)
|
||||||
|
syslog=2
|
||||||
|
user=@MYSQLD_USER@
|
||||||
|
pid_file=
|
||||||
|
err_log=
|
||||||
|
|
||||||
trap '' 1 2 3 15 # we shouldn't let anyone kill us
|
trap '' 1 2 3 15 # we shouldn't let anyone kill us
|
||||||
|
|
||||||
|
@ -38,6 +45,8 @@ Usage: $0 [OPTIONS]
|
||||||
--mysqld-version=VERSION Use "mysqld-VERSION" as mysqld
|
--mysqld-version=VERSION Use "mysqld-VERSION" as mysqld
|
||||||
--nice=NICE Set the scheduling priority of mysqld
|
--nice=NICE Set the scheduling priority of mysqld
|
||||||
--skip-kill-mysqld Don't try to kill stray mysqld processes
|
--skip-kill-mysqld Don't try to kill stray mysqld processes
|
||||||
|
--syslog Log messages to syslog with 'logger'
|
||||||
|
--skip-syslog Log messages to error log
|
||||||
|
|
||||||
All other options are passed to the mysqld program.
|
All other options are passed to the mysqld program.
|
||||||
|
|
||||||
|
@ -45,6 +54,43 @@ EOF
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_generic () {
|
||||||
|
priority="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
msg="`date +'%y%m%d %H:%M:%S'` mysqld_safe $*"
|
||||||
|
echo "$msg"
|
||||||
|
if [ $syslog -eq 0 ]
|
||||||
|
then
|
||||||
|
echo "$msg" >> "$err_log"
|
||||||
|
else
|
||||||
|
logger -i -t mysqld_safe -p "$priority" "$*"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
log_error () {
|
||||||
|
log_generic daemon.error "$@" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
log_notice () {
|
||||||
|
log_generic daemon.notice "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
eval_log_error () {
|
||||||
|
cmd="$1"
|
||||||
|
if [ $syslog -eq 0 ]
|
||||||
|
then
|
||||||
|
cmd="$cmd >> "`shell_quote_string "$err_log"`" 2>&1"
|
||||||
|
else
|
||||||
|
# mysqld often (not always) prefixes messages on stdout with a
|
||||||
|
# timestamp in the form of '%y%m%d %H:%M:%S '; this is redundant
|
||||||
|
# when logging via syslog, so strip it
|
||||||
|
cmd="$cmd 2>&1 | sed -e 's/^[0-9]\{6\} [0-9:]\{8\} *//' | logger -i -t mysqld -p daemon.error"
|
||||||
|
fi
|
||||||
|
#echo "Running mysqld: [$cmd]"
|
||||||
|
eval "$cmd"
|
||||||
|
}
|
||||||
|
|
||||||
shell_quote_string() {
|
shell_quote_string() {
|
||||||
# This sed command makes sure that any special chars are quoted,
|
# This sed command makes sure that any special chars are quoted,
|
||||||
# so the arg gets passed exactly to the server.
|
# so the arg gets passed exactly to the server.
|
||||||
|
@ -63,41 +109,41 @@ parse_arguments() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for arg do
|
for arg do
|
||||||
|
val=`echo "$arg" | sed -e "s;--[^=]*=;;"`
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
--skip-kill-mysqld*)
|
|
||||||
KILL_MYSQLD=0;
|
|
||||||
;;
|
|
||||||
# these get passed explicitly to mysqld
|
# these get passed explicitly to mysqld
|
||||||
--basedir=*) MY_BASEDIR_VERSION=`echo "$arg" | sed -e "s;--basedir=;;"` ;;
|
--basedir=*) MY_BASEDIR_VERSION="$val" ;;
|
||||||
--datadir=*) DATADIR=`echo "$arg" | sed -e "s;--datadir=;;"` ;;
|
--datadir=*) DATADIR="$val" ;;
|
||||||
--pid-file=*) pid_file=`echo "$arg" | sed -e "s;--pid-file=;;"` ;;
|
--pid-file=*) pid_file="$val" ;;
|
||||||
--user=*) user=`echo "$arg" | sed -e "s;--[^=]*=;;"` ; SET_USER=1 ;;
|
--user=*) user="$val"; SET_USER=1 ;;
|
||||||
|
|
||||||
# these might have been set in a [mysqld_safe] section of my.cnf
|
# these might have been set in a [mysqld_safe] section of my.cnf
|
||||||
# they are added to mysqld command line to override settings from my.cnf
|
# they are added to mysqld command line to override settings from my.cnf
|
||||||
--log-error=*) err_log=`echo "$arg" | sed -e "s;--log-error=;;"` ;;
|
--log-error=*) err_log="$val" ;;
|
||||||
--socket=*) mysql_unix_port=`echo "$arg" | sed -e "s;--socket=;;"` ;;
|
--port=*) mysql_tcp_port="$val" ;;
|
||||||
--port=*) mysql_tcp_port=`echo "$arg" | sed -e "s;--port=;;"` ;;
|
--socket=*) mysql_unix_port="$val" ;;
|
||||||
|
|
||||||
# mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])!
|
# mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])!
|
||||||
--ledir=*) ledir=`echo "$arg" | sed -e "s;--ledir=;;"` ;;
|
--core-file-size=*) core_file_size="$val" ;;
|
||||||
--open-files-limit=*) open_files=`echo "$arg" | sed -e "s;--open-files-limit=;;"` ;;
|
--ledir=*) ledir="$val" ;;
|
||||||
--core-file-size=*) core_file_size=`echo "$arg" | sed -e "s;--core-file-size=;;"` ;;
|
--mysqld=*) MYSQLD="$val" ;;
|
||||||
--timezone=*) TZ=`echo "$arg" | sed -e "s;--timezone=;;"` ; export TZ; ;;
|
|
||||||
--mysqld=*) MYSQLD=`echo "$arg" | sed -e "s;--mysqld=;;"` ;;
|
|
||||||
--mysqld-version=*)
|
--mysqld-version=*)
|
||||||
tmp=`echo "$arg" | sed -e "s;--mysqld-version=;;"`
|
if test -n "$val"
|
||||||
if test -n "$tmp"
|
then
|
||||||
then
|
MYSQLD="mysqld-$val"
|
||||||
MYSQLD="mysqld-$tmp"
|
else
|
||||||
else
|
MYSQLD="mysqld"
|
||||||
MYSQLD="mysqld"
|
fi
|
||||||
fi
|
|
||||||
;;
|
|
||||||
--nice=*) niceness=`echo "$arg" | sed -e "s;--nice=;;"` ;;
|
|
||||||
--help)
|
|
||||||
usage
|
|
||||||
;;
|
;;
|
||||||
|
--nice=*) niceness="$val" ;;
|
||||||
|
--open-files-limit=*) open_files="$val" ;;
|
||||||
|
--skip-kill-mysqld*) KILL_MYSQLD=0 ;;
|
||||||
|
--syslog) syslog=1 ;;
|
||||||
|
--skip-syslog) syslog=0 ;;
|
||||||
|
--timezone=*) TZ="$val"; export TZ; ;;
|
||||||
|
|
||||||
|
--help) usage ;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
if test -n "$pick_args"
|
if test -n "$pick_args"
|
||||||
then
|
then
|
||||||
|
@ -120,8 +166,7 @@ then
|
||||||
MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are
|
MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are
|
||||||
ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is
|
ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is
|
||||||
# Check for the directories we would expect from a source install
|
# Check for the directories we would expect from a source install
|
||||||
elif test -f ./share/mysql/english/errmsg.sys -a \
|
elif test -f ./share/mysql/english/errmsg.sys -a -x ./libexec/mysqld
|
||||||
-x ./libexec/mysqld
|
|
||||||
then
|
then
|
||||||
MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are
|
MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are
|
||||||
ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is
|
ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is
|
||||||
|
@ -156,17 +201,17 @@ if test -z "$MYSQL_HOME"
|
||||||
then
|
then
|
||||||
if test -r "$MY_BASEDIR_VERSION/my.cnf" && test -r "$DATADIR/my.cnf"
|
if test -r "$MY_BASEDIR_VERSION/my.cnf" && test -r "$DATADIR/my.cnf"
|
||||||
then
|
then
|
||||||
echo "WARNING: Found two instances of my.cnf -"
|
log_error "WARNING: Found two instances of my.cnf -
|
||||||
echo "$MY_BASEDIR_VERSION/my.cnf and"
|
$MY_BASEDIR_VERSION/my.cnf and
|
||||||
echo "$DATADIR/my.cnf"
|
$DATADIR/my.cnf
|
||||||
echo "IGNORING $DATADIR/my.cnf"
|
IGNORING $DATADIR/my.cnf"
|
||||||
echo
|
|
||||||
MYSQL_HOME=$MY_BASEDIR_VERSION
|
MYSQL_HOME=$MY_BASEDIR_VERSION
|
||||||
elif test -r "$DATADIR/my.cnf"
|
elif test -r "$DATADIR/my.cnf"
|
||||||
then
|
then
|
||||||
echo "WARNING: Found $DATADIR/my.cnf"
|
log_error "WARNING: Found $DATADIR/my.cnf
|
||||||
echo "Datadir is deprecated place for my.cnf, please move it to $MY_BASEDIR_VERSION"
|
The data directory is a deprecated location for my.cnf, please move it to
|
||||||
echo
|
$MY_BASEDIR_VERSION/my.cnf"
|
||||||
MYSQL_HOME=$DATADIR
|
MYSQL_HOME=$DATADIR
|
||||||
else
|
else
|
||||||
MYSQL_HOME=$MY_BASEDIR_VERSION
|
MYSQL_HOME=$MY_BASEDIR_VERSION
|
||||||
|
@ -174,12 +219,6 @@ then
|
||||||
fi
|
fi
|
||||||
export MYSQL_HOME
|
export MYSQL_HOME
|
||||||
|
|
||||||
user=@MYSQLD_USER@
|
|
||||||
niceness=0
|
|
||||||
|
|
||||||
# these rely on $DATADIR by default, so we'll set them later on
|
|
||||||
pid_file=
|
|
||||||
err_log=
|
|
||||||
|
|
||||||
# Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
|
# Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
|
||||||
# and then merge with the command line arguments
|
# and then merge with the command line arguments
|
||||||
|
@ -201,16 +240,56 @@ append_arg_to_args () {
|
||||||
}
|
}
|
||||||
|
|
||||||
args=
|
args=
|
||||||
|
|
||||||
SET_USER=2
|
SET_USER=2
|
||||||
parse_arguments `$print_defaults $defaults --loose-verbose mysqld server`
|
parse_arguments `$print_defaults $defaults --loose-verbose mysqld server`
|
||||||
if test $SET_USER -eq 2
|
if test $SET_USER -eq 2
|
||||||
then
|
then
|
||||||
SET_USER=0
|
SET_USER=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
parse_arguments `$print_defaults $defaults --loose-verbose mysqld_safe safe_mysqld`
|
parse_arguments `$print_defaults $defaults --loose-verbose mysqld_safe safe_mysqld`
|
||||||
parse_arguments PICK-ARGS-FROM-ARGV "$@"
|
parse_arguments PICK-ARGS-FROM-ARGV "$@"
|
||||||
safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@}}
|
|
||||||
|
|
||||||
|
# Determine what logging facility to use
|
||||||
|
if [ -n "$err_log" -o $syslog -eq 0 ]
|
||||||
|
then
|
||||||
|
if [ -n "$err_log" ]
|
||||||
|
then
|
||||||
|
# mysqld adds ".err" if there is no extension on the --log-err
|
||||||
|
# argument; must match that here, or mysqld_safe will write to a
|
||||||
|
# different log file than mysqld
|
||||||
|
|
||||||
|
# mysqld does not add ".err" to "--log-error=foo."; it considers a
|
||||||
|
# trailing "." as an extension
|
||||||
|
if expr "$err_log" : '.*\.[^/]*$' > /dev/null
|
||||||
|
then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
err_log="$err_log".err
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$err_log" in
|
||||||
|
/* ) ;;
|
||||||
|
* ) err_log="$DATADIR/$err_log" ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
err_log=$DATADIR/`@HOSTNAME@`.err
|
||||||
|
fi
|
||||||
|
|
||||||
|
append_arg_to_args "--log-error=$err_log"
|
||||||
|
|
||||||
|
if [ $syslog -eq 1 ]
|
||||||
|
then
|
||||||
|
# User explicitly asked for syslog, so warn that it isn't used
|
||||||
|
log_error "Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect. Logging to '$err_log'."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Don't use syslog since syslog and error log don't mix well
|
||||||
|
syslog=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@}}
|
||||||
# Make sure that directory for $safe_mysql_unix_port exists
|
# Make sure that directory for $safe_mysql_unix_port exists
|
||||||
mysql_unix_port_dir=`dirname $safe_mysql_unix_port`
|
mysql_unix_port_dir=`dirname $safe_mysql_unix_port`
|
||||||
if [ ! -d $mysql_unix_port_dir ]
|
if [ ! -d $mysql_unix_port_dir ]
|
||||||
|
@ -228,12 +307,11 @@ fi
|
||||||
|
|
||||||
if test ! -x $ledir/$MYSQLD
|
if test ! -x $ledir/$MYSQLD
|
||||||
then
|
then
|
||||||
echo "The file $ledir/$MYSQLD doesn't exist or is not executable"
|
log_error "The file $ledir/$MYSQLD
|
||||||
echo "Please do a cd to the mysql installation directory and restart"
|
does not exist or is not executable. Please cd to the mysql installation
|
||||||
echo "this script from there as follows:"
|
directory and restart this script from there as follows:
|
||||||
echo "./bin/mysqld_safe".
|
./bin/mysqld_safe&
|
||||||
echo "See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more"
|
See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more information"
|
||||||
echo "information"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -248,30 +326,6 @@ else
|
||||||
fi
|
fi
|
||||||
append_arg_to_args "--pid-file=$pid_file"
|
append_arg_to_args "--pid-file=$pid_file"
|
||||||
|
|
||||||
if [ -n "$err_log" ]
|
|
||||||
then
|
|
||||||
# mysqld adds ".err" if there is no extension on the --log-err
|
|
||||||
# argument; must match that here, or mysqld_safe will write to a
|
|
||||||
# different log file than mysqld
|
|
||||||
|
|
||||||
# mysqld does not add ".err" to "--log-error=foo."; it considers a
|
|
||||||
# trailing "." as an extension
|
|
||||||
if expr "$err_log" : '.*\.[^/]*$' > /dev/null
|
|
||||||
then
|
|
||||||
:
|
|
||||||
else
|
|
||||||
err_log="$err_log".err
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$err_log" in
|
|
||||||
/* ) ;;
|
|
||||||
* ) err_log="$DATADIR/$err_log" ;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
err_log=$DATADIR/`@HOSTNAME@`.err
|
|
||||||
fi
|
|
||||||
append_arg_to_args "--log-error=$err_log"
|
|
||||||
|
|
||||||
if test -n "$mysql_unix_port"
|
if test -n "$mysql_unix_port"
|
||||||
then
|
then
|
||||||
append_arg_to_args "--socket=$mysql_unix_port"
|
append_arg_to_args "--socket=$mysql_unix_port"
|
||||||
|
@ -296,7 +350,7 @@ fi
|
||||||
if nohup nice > /dev/null 2>&1
|
if nohup nice > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
normal_niceness=`nice`
|
normal_niceness=`nice`
|
||||||
nohup_niceness=`nohup nice`
|
nohup_niceness=`nohup nice 2>/dev/null`
|
||||||
|
|
||||||
numeric_nice_values=1
|
numeric_nice_values=1
|
||||||
for val in $normal_niceness $nohup_niceness
|
for val in $normal_niceness $nohup_niceness
|
||||||
|
@ -366,18 +420,17 @@ then
|
||||||
then
|
then
|
||||||
if @FIND_PROC@
|
if @FIND_PROC@
|
||||||
then # The pid contains a mysqld process
|
then # The pid contains a mysqld process
|
||||||
echo "A mysqld process already exists"
|
log_error "A mysqld process already exists"
|
||||||
echo "A mysqld process already exists at " `date` >> $err_log
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
rm -f $pid_file
|
rm -f $pid_file
|
||||||
if test -f $pid_file
|
if test -f $pid_file
|
||||||
then
|
then
|
||||||
echo "Fatal error: Can't remove the pid file: $pid_file"
|
log_error "Fatal error: Can't remove the pid file:
|
||||||
echo "Fatal error: Can't remove the pid file: $pid_file at " `date` >> $err_log
|
$pid_file
|
||||||
echo "Please remove it manually and start $0 again"
|
Please remove it manually and start $0 again;
|
||||||
echo "mysqld daemon not started"
|
mysqld daemon not started"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -394,33 +447,32 @@ fi
|
||||||
# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
|
# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
|
||||||
# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
|
# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
|
||||||
|
|
||||||
echo "Starting $MYSQLD daemon with databases from $DATADIR"
|
|
||||||
|
|
||||||
# Does this work on all systems?
|
# Does this work on all systems?
|
||||||
#if type ulimit | grep "shell builtin" > /dev/null
|
#if type ulimit | grep "shell builtin" > /dev/null
|
||||||
#then
|
#then
|
||||||
# ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems
|
# ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log
|
cmd="$NOHUP_NICENESS"
|
||||||
|
|
||||||
|
for i in "$ledir/$MYSQLD" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \
|
||||||
|
"--datadir=$DATADIR" "$USER_OPTION"
|
||||||
|
do
|
||||||
|
cmd="$cmd "`shell_quote_string "$i"`
|
||||||
|
done
|
||||||
|
cmd="$cmd $args"
|
||||||
|
# Avoid 'nohup: ignoring input' warning
|
||||||
|
test -n "$NOHUP_NICENESS" && cmd="$cmd < /dev/null"
|
||||||
|
|
||||||
|
log_notice "Starting $MYSQLD daemon with databases from $DATADIR"
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
rm -f $safe_mysql_unix_port $pid_file # Some extra safety
|
rm -f $safe_mysql_unix_port $pid_file # Some extra safety
|
||||||
|
|
||||||
cmd="$NOHUP_NICENESS"
|
eval_log_error "$cmd"
|
||||||
|
|
||||||
for i in "$ledir/$MYSQLD" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \
|
|
||||||
"--datadir=$DATADIR" "$USER_OPTION"
|
|
||||||
do
|
|
||||||
cmd="$cmd "`shell_quote_string "$i"`
|
|
||||||
done
|
|
||||||
cmd="$cmd $args >> "`shell_quote_string "$err_log"`" 2>&1"
|
|
||||||
#echo "Running mysqld: [$cmd]"
|
|
||||||
eval "$cmd"
|
|
||||||
|
|
||||||
if test ! -f $pid_file # This is removed if normal shutdown
|
if test ! -f $pid_file # This is removed if normal shutdown
|
||||||
then
|
then
|
||||||
echo "STOPPING server from pid file $pid_file"
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -433,7 +485,7 @@ do
|
||||||
# kill -9 is used or the process won't react on the kill.
|
# kill -9 is used or the process won't react on the kill.
|
||||||
numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"`
|
numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"`
|
||||||
|
|
||||||
echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log
|
log_notice "Number of processes running now: $numofproces"
|
||||||
I=1
|
I=1
|
||||||
while test "$I" -le "$numofproces"
|
while test "$I" -le "$numofproces"
|
||||||
do
|
do
|
||||||
|
@ -446,16 +498,15 @@ do
|
||||||
# echo "TEST $I - $T **"
|
# echo "TEST $I - $T **"
|
||||||
if kill -9 $T
|
if kill -9 $T
|
||||||
then
|
then
|
||||||
echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log
|
log_error "$MYSQLD process hanging, pid $T - killed"
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
I=`expr $I + 1`
|
I=`expr $I + 1`
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo "`date +'%y%m%d %H:%M:%S'` mysqld restarted" | tee -a $err_log
|
log_notice "mysqld restarted"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "`date +'%y%m%d %H:%M:%S'` mysqld ended" | tee -a $err_log
|
log_notice "mysqld from pid file $pid_file ended"
|
||||||
echo "" | tee -a $err_log
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue