149
149
--pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
150
--socket=*) socket=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
150
151
--service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
156
verb="$1" # created | removed
157
pid="$2" # process ID of the program operating on the pid-file
158
pid_file_path="$3" # path to the PID file.
161
avoid_race_condition="by checking again"
163
while test $i -ne $service_startup_timeout ; do
167
# wait for a PID-file to pop into existence.
168
test -s "$pid_file_path" && i='' && break
171
# wait for this PID-file to disappear
172
test ! -s "$pid_file_path" && i='' && break
175
echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path"
180
# if server isn't running, then pid-file will never be updated
181
if test -n "$pid"; then
182
if kill -0 "$pid" 2>/dev/null; then
183
: # the server still runs
185
# The server may have exited between the last pid-file check and now.
186
if test -n "$avoid_race_condition"; then
187
avoid_race_condition=""
188
continue # Check again.
191
# there's nothing that will affect the file.
192
log_failure_msg "The server quit without updating PID file ($pid_file_path)."
193
return 1 # not waiting any more.
197
echo $echo_n ".$echo_c"
203
if test -z "$i" ; then
212
156
# Get arguments from the my.cnf file,
213
157
# the only group, which is read from now on is [mysqld]
214
158
if test -x ./bin/my_print_defaults
267
211
parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`
213
# wait for the pid file to disappear
215
pid="$1" # process ID of the program operating on the pid-file
216
pid_file_path="$2" # path to the PID file.
219
crash_protection="by checking again"
221
while test $i -ne $service_startup_timeout ; do
223
if kill -0 "$pid" 2>/dev/null; then
224
: # the server still runs
226
if test ! -s "$pid_file_path"; then
227
# no server process and no pid-file? great, we're done!
232
# pid-file exists, the server process doesn't.
233
# it must've crashed, and mysqld_safe will restart it
234
if test -n "$crash_protection"; then
237
continue # Check again.
241
log_failure_msg "The server quit without updating PID file ($pid_file_path)."
242
return 1 # not waiting any more.
245
echo $echo_n ".$echo_c"
257
test -n "$socket" && sockopt="--socket=$socket"
260
while test $i -ne $service_startup_timeout ; do
262
if $bindir/mysqladmin $sockopt ping >/dev/null 2>&1; then
267
echo $echo_n ".$echo_c"
270
277
# Set pid file if not given
292
299
# Give extra arguments to mysqld with the my.cnf file. This script
293
300
# may be overwritten at next upgrade.
294
301
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
295
wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?
302
wait_for_ready; return_value=$?
297
304
# Make lock for RedHat / SuSE
298
305
if test -w "$lockdir"
319
326
echo $echo_n "Shutting down MySQL"
321
328
# mysqld should remove the pid file when it exits, so wait for it.
322
wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$?
329
wait_for_gone $mysqld_pid "$mysqld_pid_file_path"; return_value=$?
324
331
log_failure_msg "MySQL server process #$mysqld_pid is not running!"
325
332
rm "$mysqld_pid_file_path"