Make sure nginx is ready when bootstrapping with letsencrypt.

This commit is contained in:
Shuai Lin 2016-11-25 14:23:42 +08:00
parent 5061545995
commit 71390ad11f
3 changed files with 8 additions and 2 deletions

View file

@ -134,7 +134,7 @@ bootstrap() {
docker history $image >/dev/null 2>&1 || { docker history $image >/dev/null 2>&1 || {
show_progress "Pulling Seafile server image $version, this may take a while." show_progress "Pulling Seafile server image $version, this may take a while."
docker pull $image 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 # First initialize seafile server and letsencrypt

View file

@ -41,7 +41,12 @@ def init_letsencrypt():
# Create a temporary nginx conf to start a server, which would accessed by letsencrypt # Create a temporary nginx conf to start a server, which would accessed by letsencrypt
render_template('/templates/seafile.nginx.conf.template', render_template('/templates/seafile.nginx.conf.template',
'/etc/nginx/sites-enabled/seafile.nginx.conf', context) '/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('nginx -s reload')
call('/scripts/ssl.sh {0} {1}'.format(ssl_dir, domain)) 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: # if call('/scripts/ssl.sh {0} {1}'.format(ssl_dir, domain), check_call=False) != 0:
# eprint('Now waiting 1000s for postmortem') # eprint('Now waiting 1000s for postmortem')

View file

@ -40,7 +40,8 @@ def main():
json.dump(admin_pw, fp) json.dump(admin_pw, fp)
while not exists('/var/run/mysqld/mysqld.sock'): 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' print 'mysql server is ready'
try: try: