6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-12-12 14:17:46 +00:00

Fix mysql connection errror on boot

Mysql triggers "Host 'xxx' is not allowed to connect to this MySQL
server" error because of race condition.

This was an issue that had been (painfully) solved in v2 and has reared
its ugly head again in v3.

Close #159
Close #160
This commit is contained in:
Régis Behmo 2019-02-11 09:28:44 +01:00
parent 5974cb5f50
commit 09fdc30784
2 changed files with 21 additions and 9 deletions

View File

@ -2,6 +2,7 @@
## Latest
- [Bugfix] fix mysql initialization (#156, #160)
- [Improvement] Better handling of continuous integration
- [Bugfix] fix `tutor --version` (#156)
- [Improvement] Absolute settings imports -- 📯 thanks @tonytan4ever!

View File

@ -1,4 +1,5 @@
import os
import subprocess
from time import sleep
import click
@ -130,16 +131,26 @@ def run(root, service, command, args):
)
@opts.root
def databases(root):
init_mysql(root)
ops.migrate(root, run_bash)
def init_mysql(root):
mysql_data_path = tutor_env.data_path(root, "mysql", "mysql")
if not os.path.exists(mysql_data_path):
if os.path.exists(mysql_data_path):
return
click.echo(fmt.info("Initializing MySQL database..."))
docker_compose(root, "up", "-d", "mysql")
while not os.path.exists(mysql_data_path):
click.echo(fmt.info(" waiting for creation of {}".format(mysql_data_path)))
sleep(4)
while True:
click.echo(fmt.info(" waiting for mysql initialization"))
logs = subprocess.check_output([
"docker-compose", "-f", tutor_env.pathjoin(root, "local", "docker-compose.yml"),
"logs", "mysql",
])
if b"MySQL init process done. Ready for start up." in logs:
click.echo(fmt.info("MySQL database initialized"))
docker_compose(root, "stop", "mysql")
ops.migrate(root, run_bash)
return
sleep(4)
@click.group(help="Manage https certificates")
def https():