update
This commit is contained in:
@@ -52,7 +52,7 @@ function Init {
|
||||
function ImportInitSql {
|
||||
local sql_file= sql_files=
|
||||
mysql -e "CREATE USER docker@localhost IDENTIFIED BY 'China_19\$(10)!'"
|
||||
mysql -e "GRANT SHUTDOWN ON *.* TO docker@localhost"
|
||||
mysql -e "GRANT RELOAD,SHUTDOWN ON *.* TO docker@localhost"
|
||||
if sql_files="$(ls $LOG_DIR/init_sql/*.sql 2>/dev/null)"; then
|
||||
Print Importing the sql files ...
|
||||
for sql_file in $sql_files; do
|
||||
@@ -63,6 +63,18 @@ function ImportInitSql {
|
||||
fi
|
||||
}
|
||||
|
||||
function SideCar {
|
||||
local day= last_day=$(date +%d)
|
||||
while sleep 8; do
|
||||
day=$(date +%d) \
|
||||
&& [ "$day" != "$last_day" ] \
|
||||
&& last_day=$day \
|
||||
&& find $LOG_DIR -type f -name "*.log" \
|
||||
| xargs -I ^ mv -f ^ ^.$(date +%F -d yesterday) \
|
||||
&& mysqladmin flush-logs
|
||||
done
|
||||
}
|
||||
|
||||
function StartProc {
|
||||
Print Starting mysql ...
|
||||
mysqld -u mysql &
|
||||
@@ -73,6 +85,8 @@ function StartProc {
|
||||
done
|
||||
echo
|
||||
[ -z "$INIT_FLAG" ] || ImportInitSql
|
||||
SideCar &
|
||||
PIDS="$PIDS $!"
|
||||
Print MySQL is ready for connections.
|
||||
}
|
||||
|
||||
@@ -81,7 +95,7 @@ function Main {
|
||||
Init
|
||||
StartProc
|
||||
trap "GOT_SIGTERM=1; Print Got SIGTERM ..." SIGTERM
|
||||
while [ -z "$GOT_SIGTERM" ] && sleep 1; do
|
||||
while [ -z "$GOT_SIGTERM" ] && sleep 2; do
|
||||
for pid in $PIDS; do
|
||||
[ ! -e /proc/$pid ] && Print Unexpected error! && exit
|
||||
done
|
||||
|
Reference in New Issue
Block a user