From 71390ad11fc80671ed46db5c524f90c44b8e5005 Mon Sep 17 00:00:00 2001 From: Shuai Lin Date: Fri, 25 Nov 2016 14:23:42 +0800 Subject: [PATCH] Make sure nginx is ready when bootstrapping with letsencrypt. --- launcher | 2 +- scripts/bootstrap.py | 5 +++++ scripts/start.py | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/launcher b/launcher index 2d1d97e..232181c 100755 --- a/launcher +++ b/launcher @@ -134,7 +134,7 @@ bootstrap() { docker history $image >/dev/null 2>&1 || { show_progress "Pulling Seafile server image $version, this may take a while." docker pull $image - show_progress "Seafile server image $version pulled" + show_progress "Seafile server image $version pulled. Now bootstrapping the server ..." } # First initialize seafile server and letsencrypt diff --git a/scripts/bootstrap.py b/scripts/bootstrap.py index 2b822bc..e1e7c4e 100755 --- a/scripts/bootstrap.py +++ b/scripts/bootstrap.py @@ -41,7 +41,12 @@ def init_letsencrypt(): # Create a temporary nginx conf to start a server, which would accessed by letsencrypt render_template('/templates/seafile.nginx.conf.template', '/etc/nginx/sites-enabled/seafile.nginx.conf', context) + + # TODO: The 5 seconds heuristic is not good, how can we know for sure nginx is ready? + print 'waiting for mysql server to be ready' + time.sleep(5) call('nginx -s reload') + call('/scripts/ssl.sh {0} {1}'.format(ssl_dir, domain)) # if call('/scripts/ssl.sh {0} {1}'.format(ssl_dir, domain), check_call=False) != 0: # eprint('Now waiting 1000s for postmortem') diff --git a/scripts/start.py b/scripts/start.py index 4693cdf..fed22f5 100755 --- a/scripts/start.py +++ b/scripts/start.py @@ -40,7 +40,8 @@ def main(): json.dump(admin_pw, fp) while not exists('/var/run/mysqld/mysqld.sock'): - time.sleep(1) + print 'waiting for mysql server to be ready' + time.sleep(2) print 'mysql server is ready' try: