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

ps:sale - set by command line option or environmental variable. #11

Merged
merged 1 commit into from
Mar 22, 2023
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- 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.
- Dokku app names are cleaned up. Invalid characters are changed to "-". Lower case is enforced.
- ps:sale - set by command line option or environmental variable.

## Changed

Expand Down
7 changes: 7 additions & 0 deletions docs/reference/deploy-command.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,10 @@ 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`.

Scale Processes
~~~~~~~~~~~~~~~

Sets the ps:scale command, to set the number of each different type of process types to run.

Pass a string to `--psscale` or set the `DOKKUSD_PS_SCALE` environmental variable.
6 changes: 6 additions & 0 deletions dokkusd/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ def main() -> None:
help="Sets a value for Nginx Proxy Read Timeout. Include units eg 120s",
default=os.getenv("DOKKUSD_NGINX_PROXY_READ_TIMEOUT"),
)
deploy_parser.add_argument(
"--psscale",
help="Sets values for scale command. eg web=1 worker=2",
default=os.getenv("DOKKUSD_PS_SCALE"),
)

### Destroy
destroy_parser = subparsers.add_parser("destroy")
Expand Down Expand Up @@ -117,6 +122,7 @@ def main() -> None:
environment_variables=env_vars,
nginx_client_max_body_size=args.nginxclientmaxbodysize,
nginx_proxy_read_timeout=args.nginxproxyreadtimeout,
ps_scale=args.psscale,
)
deploy.go()

Expand Down
15 changes: 15 additions & 0 deletions dokkusd/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(
environment_variables: dict = {},
nginx_client_max_body_size=None,
nginx_proxy_read_timeout=None,
ps_scale=None,
):
super().__init__(
directory=directory,
Expand All @@ -38,6 +39,7 @@ def __init__(
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
self._ps_scale = ps_scale

def go(self) -> None:

Expand Down Expand Up @@ -173,6 +175,19 @@ def go(self) -> None:
print(stdout)
print(stderr)

# --------------------- PS scale
if self._ps_scale:
print("Ps: scale ...")
command = [
"ps:scale",
self.app_name,
"--skip-deploy",
]
command.extend([i.strip() for i in self._ps_scale.split(" ") if i.strip()])
stdout, stderr = self._dokku_command(command)
print(stdout)
print(stderr)

# --------------------- Deploy
print("Deploy ...")
process = subprocess.Popen(
Expand Down