Skip to content

Commit

Permalink
nginx / proxy-read-timeout option
Browse files Browse the repository at this point in the history
  • Loading branch information
odscjames committed Mar 17, 2023
1 parent 51ed959 commit 03deada
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions docs/reference/deploy-command.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
7 changes: 7 additions & 0 deletions dokkusd/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down
22 changes: 21 additions & 1 deletion dokkusd/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 03deada

Please sign in to comment.