Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wait_for_memcached #260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts_8.0/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from utils import (
call, get_conf, get_install_dir, get_script, get_command_output,
render_template, wait_for_mysql, setup_logging
render_template, wait_for_mysql, wait_for_memcached, setup_logging
)
from upgrade import check_upgrade
from bootstrap import init_seafile_server, is_https, init_letsencrypt, generate_local_nginx_conf
Expand Down Expand Up @@ -53,6 +53,7 @@ def main():
call('nginx -s reload')

wait_for_mysql()
wait_for_memcached()
init_seafile_server()

check_upgrade()
Expand Down
13 changes: 13 additions & 0 deletions scripts_8.0/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import termcolor
import colorlog
import pymysql
import telnetlib

logger = logging.getLogger('.utils')

Expand Down Expand Up @@ -281,6 +282,18 @@ def wait_for_mysql():
logdbg('mysql server is ready')
return

def wait_for_memcached():
while True:
try:
with telnetlib.Telnet(host='memcached', port=11211, timeout=3) as tn:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello!
I came here to have a look at the memcached configuration options.
As far as I see it, there is no MEMCACHED_HOST environment variable, but I guess one day there might be one.

Making this MR future-proof, one could already now add it here.

As the default value would be used when no configuration is provided, I only see this as saving some work when adding the memcached config later.

host=get_conf('MEMCACHED_HOST', 'memcached')

pass
except Exception as e:
print ('waiting for memcached to be ready: %s', e)
time.sleep(2)
continue
logdbg('memcached is ready')
return

def wait_for_nginx():
while True:
logdbg('waiting for nginx server to be ready')
Expand Down