Skip to content
This repository has been archived by the owner on Aug 26, 2020. It is now read-only.

Commit

Permalink
set nginx proxy timeout >= gunicorn timeout (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesterhazy authored Apr 18, 2019
1 parent af64014 commit 5f374db
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
CHANGELOG
=========

1.1.3
=====

* bug-fix: make sure nginx proxy_read_timeout >= gunicorn worker timeout

1.1.2
=====

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def read(fname):

setup(
name='sagemaker_container_support',
version='1.1.2',
version='1.1.3',
description='Open source library for creating containers to run on Amazon SageMaker.',

packages=[PKG_NAME],
Expand Down
1 change: 1 addition & 0 deletions src/container_support/etc/nginx.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ http {
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://gunicorn;
proxy_read_timeout %NGINX_PROXY_READ_TIMEOUT%;
}

location / {
Expand Down
9 changes: 8 additions & 1 deletion src/container_support/serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,16 @@ def _create_nginx_config(serving_env):
template = cs.utils.read_file(nginx_config_template_file)
pattern = re.compile(r'%(\w+)%')

# make sure nginx proxy timeout >= gunicorn timeout
proxy_read_timeout = 60
if int(serving_env.model_server_timeout) > 60:
proxy_read_timeout = int(serving_env.model_server_timeout)

template_values = {
'NGINX_HTTP_PORT': serving_env.http_port
'NGINX_HTTP_PORT': serving_env.http_port,
'NGINX_PROXY_READ_TIMEOUT': str(proxy_read_timeout)
}

config = pattern.sub(lambda x: template_values[x.group(1)], template)
logger.info('nginx config: \n%s\n', config)
cs.utils.write_file(nginx_config_file, config)
Expand Down

0 comments on commit 5f374db

Please sign in to comment.