Skip to content
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,7 @@ __marimo__/

# Streamlit
.streamlit/secrets.toml

# VIM files
.*.sw?
.*.un~
5 changes: 4 additions & 1 deletion site-docs/docs/commands/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ deploy [--config FILE] update <instance_name> [<ssh_host>] \
|--------|---------|-------------|
| `--type` | auto | Deployment type: `odoo`, `python`, or `service` |
| `-p`, `--port` | — | SSH port on the remote host |
| `--db` | `<instance_name>` | Override target database name (Odoo only) |
| `--db` | `<instance_name>` | Override target database name (Odoo only). Can be a list of comma-separated names |
| `--ignore-hooks` | `False` | Skip all hook execution |
| `--watch` | `False` | Watch service logs for working information |

Expand Down Expand Up @@ -87,6 +87,9 @@ deploy update odoo-myproject-production
# Override database name
deploy update odoo-myproject-production --db myproject_alt

# Multiple database names
deploy update odoo-myproject-production --db myproject_alt,myproject_staging

# Custom SSH port
deploy update odoo-myproject-staging -p 2222

Expand Down
7 changes: 6 additions & 1 deletion site-docs/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ odoo-myproject-production:
# Odoo only
db: myproject # defaults to instance_name if omitted

# Multiple databases
db:
- myproject_staging
- myproject_integration

# python / service only
exec_start: myapp.main:app # module path for python; verbatim for service
build: npm ci && npm run build # service only
Expand Down Expand Up @@ -66,7 +71,7 @@ odoo-myproject-production:
| `ssh_port` | integer | all | SSH port on the remote host. |
| `repo_url` | string | `configure` | Git repository URL. |
| `type` | string | all | Deployment type: `odoo`, `python`, or `service`. |
| `db` | string | `update` | Target database name (Odoo only). |
| `db` | string or list of string | `update` | Target database name (Odoo only). Can be a list for multiple names. |
| `exec_start` | string | `configure` | Entry point for python/service systemd unit. |
| `build` | string | `configure`, `update` | Build command for `service` type. |
| `hooks` | mapping | `update` | Lifecycle hooks — see [Hooks](hooks.md). |
Expand Down
16 changes: 10 additions & 6 deletions trobz_deploy/command/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@click.option(
"--db",
default=None,
help="Override the target database name (Odoo only).",
help="Override the target database name (Odoo only). Can be comma-separated for multiple databases.",
)
@click.option(
"-p",
Expand Down Expand Up @@ -89,7 +89,9 @@ def update( # noqa: C901
eff_ssh_host: str | None = opts.get("ssh_host")
eff_ssh_port: int | None = opts.get("ssh_port")
eff_type: str = opts["type"]
eff_db: str = opts.get("db", instance_name)
eff_db: str | list[str] = opts.get("db", instance_name)
if isinstance(eff_db, str):
eff_db = eff_db.split(",")
eff_repo_branch: str | None = opts.get("repo_branch")
_req = opts.get("requirements")
eff_requirements: list[str] = ([_req] if isinstance(_req, str) else _req) if _req else []
Expand Down Expand Up @@ -196,10 +198,12 @@ def run_hooks(hook_name: str) -> bool:
try:
if eff_type == "odoo":
addons_path = get_addons_path(executor, instance_path)
executor.run(
f".venv/bin/click-odoo-update -d {eff_db} --addons-path={addons_path}",
cwd=instance_path,
)
for db in eff_db:
click.secho(f"\nUpdating database {db!r}…", fg="green")
executor.run(
f".venv/bin/click-odoo-update -d {db} --addons-path={addons_path}",
cwd=instance_path,
)
executor.run(f"systemctl --user restart {instance_name}")
except ExecutorError as exc:
run_hooks("post-update")
Expand Down