~percona-dev/percona-server/release-5.0.91-22

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
diff -r d91edeb58b50 patch_info/mysqld_safe_syslog.info
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patch_info/mysqld_safe_syslog.info	Mon Sep 01 21:58:00 2008 -0700
@@ -0,0 +1,6 @@
+File=mysqld_safe_syslog.patch
+Name=Patch allows redirect output of error.log to syslog-ng
+Version=1.0
+Author=Percona <info@percona.com>
+License=GPL
+Comment=Ported from Debian
diff -r d91edeb58b50 scripts/mysqld_safe.sh
--- a/scripts/mysqld_safe.sh	Mon Sep 01 21:57:21 2008 -0700
+++ b/scripts/mysqld_safe.sh	Mon Sep 01 21:58:00 2008 -0700
@@ -10,12 +10,16 @@
 # mysql.server works by first doing a cd to the base directory and from there
 # executing mysqld_safe
 
-KILL_MYSQLD=1;
 MYSQLD=
 
 trap '' 1 2 3 15			# we shouldn't let anyone kill us
 
 umask 007
+
+KILL_MYSQLD=1;
+
+# This command can be used as pipe to syslog. With "-s" it also logs to stderr.
+ERR_LOGGER="logger -p daemon.err -t mysqld_safe -i"
 
 defaults=
 case "$1" in
@@ -177,7 +181,6 @@
 
 # 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]
 # and then merge with the command line arguments
@@ -245,7 +248,6 @@
     * )  pid_file="$DATADIR/$pid_file" ;;
   esac
 fi
-test -z "$err_log"  && err_log=$DATADIR/`@HOSTNAME@`.err
 
 if test -n "$mysql_unix_port"
 then
@@ -315,8 +317,6 @@
   then
     USER_OPTION="--user=$user"
   fi
-  # If we are root, change the err log to the right user.
-  touch $err_log; chown $user $err_log
   if test -n "$open_files"
   then
     ulimit -n $open_files
@@ -341,18 +341,16 @@
   then
     if @FIND_PROC@
     then    # The pid contains a mysqld process
-      echo "A mysqld process already exists"
-      echo "A mysqld process already exists at " `date` >> $err_log
+      echo "A mysqld process already exists" | $ERR_LOGGER -s
       exit 1
     fi
   fi
   rm -f $pid_file
   if test -f $pid_file
   then
-    echo "Fatal error: Can't remove the pid file: $pid_file"
-    echo "Fatal error: Can't remove the pid file: $pid_file at " `date` >> $err_log
-    echo "Please remove it manually and start $0 again"
-    echo "mysqld daemon not started"
+    echo "Fatal error: Can't remove the pid file: $pid_file" | $ERR_LOGGER -s
+    echo "Please remove it manually and start $0 again" | $ERR_LOGGER -s
+    echo "mysqld daemon not started" | $ERR_LOGGER -s
     exit 1
   fi
 fi
@@ -377,15 +375,15 @@
 #  ulimit -n 256 > /dev/null 2>&1		# Fix for BSD and FreeBSD systems
 #fi
 
-echo "`date +'%y%m%d %H:%M:%S  mysqld started'`" >> $err_log
+echo "started" | $ERR_LOGGER -s
 while true
 do
   rm -f $safe_mysql_unix_port $pid_file	# Some extra safety
   if test -z "$args"
   then
-    $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1
+    $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ 2>&1 | $ERR_LOGGER -t mysqld
   else
-    eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args >> $err_log 2>&1"
+    eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args 2>&1 | $ERR_LOGGER -t mysqld"
   fi
   if test ! -f $pid_file		# This is removed if normal shutdown
   then
@@ -402,7 +400,7 @@
     # 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"`
 
-    echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log
+    echo -e "\nNumber of processes running now: $numofproces" | $ERR_LOGGER -s
     I=1
     while test "$I" -le "$numofproces"
     do 
@@ -415,16 +413,14 @@
       #    echo "TEST $I - $T **"
       if kill -9 $T
       then
-        echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log
+        echo "$MYSQLD process hanging, pid $T - killed" | $ERR_LOGGER -s
       else 
         break
       fi
       I=`expr $I + 1`
     done
   fi
-  echo "`date +'%y%m%d %H:%M:%S'`  mysqld restarted" | tee -a $err_log
+  echo "restarted" | $ERR_LOGGER -s
 done
 
-echo "`date +'%y%m%d %H:%M:%S'`  mysqld ended" | tee -a $err_log
-echo "" | tee -a $err_log
-
+echo "ended" | $ERR_LOGGER -s