You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Template: Create functions for starting and stopping server during init
Move the logic for doing temporary startup of the server during init to functions.
Also add tags to echo commands to make it clear they are coming from the entrypoint
script.
ERROR: mysqld failed while attempting to check config
67
+
$datestring [ERROR] [Entrypoint]: mysqld failed while attempting to check config
67
68
command was: "${toRun[*]}"
68
69
69
70
$errors
@@ -82,6 +83,40 @@ _get_config() {
82
83
# match "datadir /some/path with/spaces in/it here" but not "--xyz=abc\n datadir (xyz)"
83
84
}
84
85
86
+
_start_server() {
87
+
local socket=$1;shift
88
+
"$@" --skip-networking --socket="${socket}"&
89
+
local pid="$!"
90
+
91
+
mysql=( mysql --protocol=socket -uroot -hlocalhost --socket="${socket}" )
92
+
93
+
foriin {30..0};do
94
+
ifecho'SELECT 1'|"${mysql[@]}"&> /dev/null;then
95
+
break
96
+
fi
97
+
sleep 1
98
+
done
99
+
if [ "$i"= 0 ];then
100
+
echo>&2"$(date --rfc-3339=seconds) [ERROR] [Entrypoint]: Unable to start server."
101
+
exit 1
102
+
fi
103
+
return$pid
104
+
}
105
+
106
+
_stop_server() {
107
+
local server_pid="$1"
108
+
kill"$server_pid"
109
+
foriin$(seq 1 60);do
110
+
sleep 1
111
+
if!$(pidof /usr/sbin/mysqld >/dev/null 2>&1);then
112
+
return 0
113
+
fi
114
+
done
115
+
# The server hasn't shut down in a timely manner
116
+
echo"$(date --rfc-3339=seconds) [ERROR] [Entrypoint]: Unable to shut down server with process id $server_pid">&2
117
+
return 1
118
+
119
+
}
85
120
# allow the container to be started with `--user`
86
121
if [ "$1"='mysqld'-a-z"$wantHelp"-a"$(id -u)"='0' ];then
87
122
_check_config "$@"
@@ -100,50 +135,39 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
100
135
if [ !-d"$DATADIR/mysql" ];then
101
136
file_env 'MYSQL_ROOT_PASSWORD'
102
137
if [ -z"$MYSQL_ROOT_PASSWORD"-a-z"$MYSQL_ALLOW_EMPTY_PASSWORD"-a-z"$MYSQL_RANDOM_ROOT_PASSWORD" ];then
103
-
echo>&2'error: database is uninitialized and password option is not specified '
104
-
echo>&2'You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD'
138
+
echo>&2"$(date --rfc-3339=seconds) [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified "
139
+
echo>&2"$(date --rfc-3339=seconds) [ERROR] [Entrypoint]: You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD"
0 commit comments