From 03deada90a3c2cc5e9d2bc65c0c488530c1f449f Mon Sep 17 00:00:00 2001 From: James B Date: Fri, 17 Mar 2023 12:29:33 +0000 Subject: [PATCH] nginx / proxy-read-timeout option https://github.com/OpenDataServices/dokkusd-client/issues/7 --- CHANGELOG.md | 1 + docs/reference/deploy-command.rst | 9 +++++++++ dokkusd/cli.py | 7 +++++++ dokkusd/deploy.py | 22 +++++++++++++++++++++- 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa57aab..211fe14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Added - nginx / client_max_body_size option - set by command line option or environmental variable. +- nginx / proxy-read-timeout option - set by command line option or environmental variable. ## Changed diff --git a/docs/reference/deploy-command.rst b/docs/reference/deploy-command.rst index b6d7992..0c9e16f 100644 --- a/docs/reference/deploy-command.rst +++ b/docs/reference/deploy-command.rst @@ -88,3 +88,12 @@ Sets the Nginx Client Max body size. Pass a string to `--nginxclientmaxbodysize` or set the `DOKKUSD_NGINX_CLIENT_MAX_BODY_SIZE` environmental variable. Should include units. eg `50m` not `50`. + +Nginx Proxy Read Timeout +~~~~~~~~~~~~~~~~~~~~~~~~ + +Sets the Nginx Proxy Read Timeout. + +Pass a string to `--nginxproxyreadtimeout` or set the `DOKKUSD_NGINX_PROXY_READ_TIMEOUT` environmental variable. + +Should include units. eg `120s` not `120`. diff --git a/dokkusd/cli.py b/dokkusd/cli.py index 8458765..edfe041 100644 --- a/dokkusd/cli.py +++ b/dokkusd/cli.py @@ -58,6 +58,12 @@ def main() -> None: default=os.getenv("DOKKUSD_NGINX_CLIENT_MAX_BODY_SIZE"), ) + deploy_parser.add_argument( + "--nginxproxyreadtimeout", + help="Sets a value for Nginx Proxy Read Timeout. Include units eg 120s", + default=os.getenv("DOKKUSD_NGINX_PROXY_READ_TIMEOUT"), + ) + ### Destroy destroy_parser = subparsers.add_parser("destroy") # host @@ -110,6 +116,7 @@ def main() -> None: environment_variables_json_string=args.environmentvariablesjson, environment_variables=env_vars, nginx_client_max_body_size=args.nginxclientmaxbodysize, + nginx_proxy_read_timeout=args.nginxproxyreadtimeout, ) deploy.go() diff --git a/dokkusd/deploy.py b/dokkusd/deploy.py index fefd646..2dbf7b3 100644 --- a/dokkusd/deploy.py +++ b/dokkusd/deploy.py @@ -23,6 +23,7 @@ def __init__( environment_variables_json_string: str = None, environment_variables: dict = {}, nginx_client_max_body_size=None, + nginx_proxy_read_timeout=None, ): super().__init__( directory=directory, @@ -36,6 +37,7 @@ def __init__( self._environment_variables: dict = environment_variables self.environment_variables_json_string = environment_variables_json_string self._nginx_client_max_body_size = nginx_client_max_body_size + self._nginx_proxy_read_timeout = nginx_proxy_read_timeout def go(self) -> None: @@ -125,7 +127,7 @@ def go(self) -> None: print(stdout) print(stderr) - # --------------------- Nginx + # --------------------- Nginx Client Max Body Size # If not already passed, look for it in app.json # This way things passed to us take priority over things set in app.json # Setting in app.json is deprecated and undocumented. @@ -153,6 +155,24 @@ def go(self) -> None: print(stdout) print(stderr) + # --------------------- Nginx Proxy Read Timeout + if self._nginx_proxy_read_timeout: + print("Nginx: proxy-read-timeout ...") + stdout, stderr = self._dokku_command( + [ + "nginx:set", + self.app_name, + "proxy-read-timeout", + str(self._nginx_proxy_read_timeout), + ] + ) + print(stdout) + print(stderr) + print("proxy:build-config after Nginx: proxy-read-timeout ...") + stdout, stderr = self._dokku_command(["proxy:build-config", self.app_name]) + print(stdout) + print(stderr) + # --------------------- Deploy print("Deploy ...") process = subprocess.Popen(