mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-12-12 06:07:56 +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:
parent
5974cb5f50
commit
09fdc30784
@ -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!
|
||||
|
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import subprocess
|
||||
from time import sleep
|
||||
|
||||
import click
|
||||
@ -130,17 +131,27 @@ def run(root, service, command, args):
|
||||
)
|
||||
@opts.root
|
||||
def databases(root):
|
||||
mysql_data_path = tutor_env.data_path(root, "mysql", "mysql")
|
||||
if not os.path.exists(mysql_data_path):
|
||||
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)
|
||||
click.echo(fmt.info("MySQL database initialized"))
|
||||
docker_compose(root, "stop", "mysql")
|
||||
init_mysql(root)
|
||||
ops.migrate(root, run_bash)
|
||||
|
||||
def init_mysql(root):
|
||||
mysql_data_path = tutor_env.data_path(root, "mysql", "mysql")
|
||||
if os.path.exists(mysql_data_path):
|
||||
return
|
||||
click.echo(fmt.info("Initializing MySQL database..."))
|
||||
docker_compose(root, "up", "-d", "mysql")
|
||||
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")
|
||||
return
|
||||
sleep(4)
|
||||
|
||||
@click.group(help="Manage https certificates")
|
||||
def https():
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user