2018-11-07 02:12:31 +01:00
|
|
|
#!/usr/bin/env python3
|
2020-06-11 00:54:34 +02:00
|
|
|
import argparse
|
|
|
|
import logging
|
2018-11-07 02:12:31 +01:00
|
|
|
import os
|
|
|
|
import subprocess
|
2020-06-11 00:54:34 +02:00
|
|
|
import sys
|
2018-11-07 02:12:31 +01:00
|
|
|
import time
|
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
LOCAL_GIT_CACHE_DIR = "/srv/zulip.git"
|
2018-11-07 02:12:31 +01:00
|
|
|
os.environ["PYTHONUNBUFFERED"] = "y"
|
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
|
2020-06-11 00:54:34 +02:00
|
|
|
from scripts.lib.zulip_tools import (
|
|
|
|
DEPLOYMENTS_DIR,
|
|
|
|
assert_running_as_root,
|
|
|
|
get_config,
|
|
|
|
get_config_file,
|
|
|
|
get_deploy_options,
|
|
|
|
get_deployment_lock,
|
|
|
|
make_deploy_path,
|
|
|
|
overwrite_symlink,
|
|
|
|
release_deployment_lock,
|
|
|
|
su_to_zulip,
|
|
|
|
)
|
2018-12-15 07:05:27 +01:00
|
|
|
|
|
|
|
config_file = get_config_file()
|
|
|
|
deploy_options = get_deploy_options(config_file)
|
2021-05-06 21:49:07 +02:00
|
|
|
upstream_url = "https://github.com/zulip/zulip.git"
|
|
|
|
remote_url = get_config(config_file, "deployment", "git_repo_url", upstream_url)
|
2018-11-15 11:07:43 +01:00
|
|
|
|
2018-11-19 19:50:25 +01:00
|
|
|
assert_running_as_root(strip_lib_from_paths=True)
|
2018-11-07 02:12:31 +01:00
|
|
|
|
2020-06-08 21:37:16 +02:00
|
|
|
# make sure we have appropriate file permissions
|
|
|
|
os.umask(0o22)
|
|
|
|
|
2018-11-07 02:12:31 +01:00
|
|
|
logging.Formatter.converter = time.gmtime
|
2021-02-12 08:19:30 +01:00
|
|
|
logging.basicConfig(format="%(asctime)s upgrade-zulip-from-git: %(message)s", level=logging.INFO)
|
2018-11-07 02:12:31 +01:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("refname", help="Git reference, e.g. a branch, tag, or commit ID.")
|
2021-02-12 08:19:30 +01:00
|
|
|
parser.add_argument(
|
|
|
|
"--remote-url", help="Override the Git remote URL configured in /etc/zulip/zulip.conf."
|
|
|
|
)
|
2021-12-11 00:46:51 +01:00
|
|
|
args, extra_options = parser.parse_known_args()
|
2018-11-07 02:12:31 +01:00
|
|
|
|
|
|
|
refname = args.refname
|
|
|
|
# Command line remote URL will be given preference above the one
|
|
|
|
# in /etc/zulip/zulip.conf.
|
|
|
|
if args.remote_url:
|
|
|
|
remote_url = args.remote_url
|
|
|
|
|
2018-07-18 23:50:15 +02:00
|
|
|
os.makedirs(DEPLOYMENTS_DIR, exist_ok=True)
|
2021-02-12 08:20:45 +01:00
|
|
|
os.makedirs("/home/zulip/logs", exist_ok=True)
|
2018-11-07 02:12:31 +01:00
|
|
|
|
2020-06-10 06:41:04 +02:00
|
|
|
error_rerun_script = f"{DEPLOYMENTS_DIR}/current/scripts/upgrade-zulip-from-git {refname}"
|
2018-11-07 02:12:31 +01:00
|
|
|
get_deployment_lock(error_rerun_script)
|
|
|
|
|
|
|
|
try:
|
|
|
|
deploy_path = make_deploy_path()
|
2021-05-06 21:49:07 +02:00
|
|
|
|
|
|
|
# Populate LOCAL_GIT_CACHE_DIR with both the requested remote and zulip/zulip.
|
2018-11-07 02:12:31 +01:00
|
|
|
if not os.path.exists(LOCAL_GIT_CACHE_DIR):
|
|
|
|
logging.info("Cloning the repository")
|
2021-02-12 08:19:30 +01:00
|
|
|
subprocess.check_call(
|
upgrade-zulip-from-git: Stop mirroring the remote.
The local `/srv/zulip.git` directory has been cloned with `--mirror`
since it was first created as a local cache in dc4b89fb085f. This
made some sense at the time, since it was purely a cache of the
remote, and not a home to local branches of its own.
That changed in 3f83b843c24a, when we began using `git worktree`,
which caused the `deployment-...` branches to begin being stored in
`/src/zulip.git`. This caused intermixing of local and remote
branches.
When 02582c695603 landed, the addition of `--prune` caused all but the
most recent deployment branch to be deleted upon every fetch --
leaving previous deployments with non-existent branches checked out:
```
zulip@example-prod-host:~/deployments/last$ git status
On branch deployment-2022-04-15-23-07-55
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .browserslistrc
new file: .codecov.yml
new file: .codespellignore
new file: .editorconfig
[...snip list of every file in repo...]
```
Switch `/srv/zulip.git` to no longer be a `--mirror` cache of the
origin. We reconfigure the remote to drop `remote.origin.mirror`, and
delete all refs under `refs/pulls/` and `refs/heads/`, while
preserving any checked-out branches. `refs/pulls/`, if the remote is
the canonical upstream, contains _tens of thousands_ of refs, so
pruning those refs trims off 20% of the repository size.
Those savings require a `git gc --prune=now`, otherwise the dangling
objects are ejected from the packfiles, which would balloon the
repository up to more than three times its previous size. Repacking
the repository is reasonable, in general, after removing such a large
number of refs -- and the `--prune=now` is safe and will not lose
data, as the `--mirror` was good at ensuring that the repository could
not be used for any local state.
The refname in the upgrade process was previously resolved from the
union of local and remote refs, since they were in the same namespace.
We instead now only resolve arguments as tags, then origin branches;
this means that stale local branches will be skipped. Users who want
to deploy from local branches can use `--remote-url=.`.
Because the `scripts/lib/upgrade-zulip-from-git` file is "stage 1" and
run from the old version's code, this will take two invocations of
`upgrade-zulip-from-git` to take effect.
Fixes #21901.
2022-05-12 22:45:18 +02:00
|
|
|
["git", "clone", "-q", remote_url, LOCAL_GIT_CACHE_DIR],
|
2021-05-13 21:53:04 +02:00
|
|
|
stdout=subprocess.DEVNULL,
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
upgrade-zulip-from-git: Stop mirroring the remote.
The local `/srv/zulip.git` directory has been cloned with `--mirror`
since it was first created as a local cache in dc4b89fb085f. This
made some sense at the time, since it was purely a cache of the
remote, and not a home to local branches of its own.
That changed in 3f83b843c24a, when we began using `git worktree`,
which caused the `deployment-...` branches to begin being stored in
`/src/zulip.git`. This caused intermixing of local and remote
branches.
When 02582c695603 landed, the addition of `--prune` caused all but the
most recent deployment branch to be deleted upon every fetch --
leaving previous deployments with non-existent branches checked out:
```
zulip@example-prod-host:~/deployments/last$ git status
On branch deployment-2022-04-15-23-07-55
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .browserslistrc
new file: .codecov.yml
new file: .codespellignore
new file: .editorconfig
[...snip list of every file in repo...]
```
Switch `/srv/zulip.git` to no longer be a `--mirror` cache of the
origin. We reconfigure the remote to drop `remote.origin.mirror`, and
delete all refs under `refs/pulls/` and `refs/heads/`, while
preserving any checked-out branches. `refs/pulls/`, if the remote is
the canonical upstream, contains _tens of thousands_ of refs, so
pruning those refs trims off 20% of the repository size.
Those savings require a `git gc --prune=now`, otherwise the dangling
objects are ejected from the packfiles, which would balloon the
repository up to more than three times its previous size. Repacking
the repository is reasonable, in general, after removing such a large
number of refs -- and the `--prune=now` is safe and will not lose
data, as the `--mirror` was good at ensuring that the repository could
not be used for any local state.
The refname in the upgrade process was previously resolved from the
union of local and remote refs, since they were in the same namespace.
We instead now only resolve arguments as tags, then origin branches;
this means that stale local branches will be skipped. Users who want
to deploy from local branches can use `--remote-url=.`.
Because the `scripts/lib/upgrade-zulip-from-git` file is "stage 1" and
run from the old version's code, this will take two invocations of
`upgrade-zulip-from-git` to take effect.
Fixes #21901.
2022-05-12 22:45:18 +02:00
|
|
|
|
2019-06-18 02:24:30 +02:00
|
|
|
if os.stat(LOCAL_GIT_CACHE_DIR).st_uid == 0:
|
2018-11-07 02:12:31 +01:00
|
|
|
subprocess.check_call(["chown", "-R", "zulip:zulip", LOCAL_GIT_CACHE_DIR])
|
|
|
|
|
|
|
|
os.chdir(LOCAL_GIT_CACHE_DIR)
|
2021-02-12 08:19:30 +01:00
|
|
|
subprocess.check_call(
|
|
|
|
["git", "remote", "set-url", "origin", remote_url], preexec_fn=su_to_zulip
|
|
|
|
)
|
2018-11-07 02:12:31 +01:00
|
|
|
|
upgrade-zulip-from-git: Stop mirroring the remote.
The local `/srv/zulip.git` directory has been cloned with `--mirror`
since it was first created as a local cache in dc4b89fb085f. This
made some sense at the time, since it was purely a cache of the
remote, and not a home to local branches of its own.
That changed in 3f83b843c24a, when we began using `git worktree`,
which caused the `deployment-...` branches to begin being stored in
`/src/zulip.git`. This caused intermixing of local and remote
branches.
When 02582c695603 landed, the addition of `--prune` caused all but the
most recent deployment branch to be deleted upon every fetch --
leaving previous deployments with non-existent branches checked out:
```
zulip@example-prod-host:~/deployments/last$ git status
On branch deployment-2022-04-15-23-07-55
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .browserslistrc
new file: .codecov.yml
new file: .codespellignore
new file: .editorconfig
[...snip list of every file in repo...]
```
Switch `/srv/zulip.git` to no longer be a `--mirror` cache of the
origin. We reconfigure the remote to drop `remote.origin.mirror`, and
delete all refs under `refs/pulls/` and `refs/heads/`, while
preserving any checked-out branches. `refs/pulls/`, if the remote is
the canonical upstream, contains _tens of thousands_ of refs, so
pruning those refs trims off 20% of the repository size.
Those savings require a `git gc --prune=now`, otherwise the dangling
objects are ejected from the packfiles, which would balloon the
repository up to more than three times its previous size. Repacking
the repository is reasonable, in general, after removing such a large
number of refs -- and the `--prune=now` is safe and will not lose
data, as the `--mirror` was good at ensuring that the repository could
not be used for any local state.
The refname in the upgrade process was previously resolved from the
union of local and remote refs, since they were in the same namespace.
We instead now only resolve arguments as tags, then origin branches;
this means that stale local branches will be skipped. Users who want
to deploy from local branches can use `--remote-url=.`.
Because the `scripts/lib/upgrade-zulip-from-git` file is "stage 1" and
run from the old version's code, this will take two invocations of
`upgrade-zulip-from-git` to take effect.
Fixes #21901.
2022-05-12 22:45:18 +02:00
|
|
|
# Check to see if it's the old "mirror" configuration
|
|
|
|
is_mirror = subprocess.check_output(
|
|
|
|
["git", "config", "--bool", "--default=false", "remote.origin.mirror"],
|
|
|
|
preexec_fn=su_to_zulip,
|
|
|
|
text=True,
|
|
|
|
)
|
|
|
|
if is_mirror.strip() == "true":
|
|
|
|
subprocess.check_call(
|
|
|
|
["git", "config", "--unset", "remote.origin.mirror"],
|
|
|
|
preexec_fn=su_to_zulip,
|
|
|
|
)
|
|
|
|
subprocess.check_call(
|
|
|
|
["git", "config", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*"],
|
|
|
|
preexec_fn=su_to_zulip,
|
|
|
|
)
|
|
|
|
matching_refs = subprocess.check_output(
|
|
|
|
["git", "for-each-ref", "--format=%(refname)", "refs/pull/", "refs/heads/"],
|
|
|
|
preexec_fn=su_to_zulip,
|
|
|
|
text=True,
|
|
|
|
).splitlines()
|
|
|
|
|
|
|
|
# We can't use `git worktree list --porcelain -z` here because
|
|
|
|
# Ubuntu 20.04 Focal only has git 2.25.1, and -z was
|
|
|
|
# introduced in 2.36
|
|
|
|
worktree_data = subprocess.check_output(
|
|
|
|
["git", "worktree", "list", "--porcelain"],
|
|
|
|
preexec_fn=su_to_zulip,
|
|
|
|
text=True,
|
|
|
|
).splitlines()
|
|
|
|
keep_refs = set()
|
|
|
|
for worktree_line in worktree_data:
|
|
|
|
if worktree_line.startswith("branch "):
|
|
|
|
keep_refs.add(worktree_line[len("branch ") :])
|
|
|
|
|
|
|
|
delete_input = "".join(
|
|
|
|
f"delete {refname}\n" for refname in matching_refs if refname not in keep_refs
|
|
|
|
)
|
|
|
|
subprocess.run(
|
|
|
|
["git", "update-ref", "--stdin"],
|
|
|
|
check=True,
|
|
|
|
preexec_fn=su_to_zulip,
|
|
|
|
input=delete_input,
|
|
|
|
text=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
logging.info("Repacking repository after pruning unnecessary refs...")
|
|
|
|
subprocess.check_call(
|
|
|
|
["git", "gc", "--prune=now"],
|
|
|
|
preexec_fn=su_to_zulip,
|
|
|
|
)
|
|
|
|
|
2021-05-06 21:49:07 +02:00
|
|
|
# Ensure upstream remote is configured; we need this to make `git describe` accurate.
|
|
|
|
remotes = subprocess.check_output(["git", "remote"], preexec_fn=su_to_zulip).split(b"\n")
|
|
|
|
if b"upstream" not in remotes:
|
|
|
|
subprocess.check_call(
|
2022-01-19 02:21:14 +01:00
|
|
|
["git", "remote", "add", "upstream", upstream_url], preexec_fn=su_to_zulip
|
2021-05-06 21:49:07 +02:00
|
|
|
)
|
2022-01-19 04:43:17 +01:00
|
|
|
else:
|
|
|
|
subprocess.check_call(
|
|
|
|
["git", "remote", "set-url", "upstream", upstream_url], preexec_fn=su_to_zulip
|
|
|
|
)
|
2021-05-06 21:49:07 +02:00
|
|
|
|
|
|
|
logging.info("Fetching the latest commits")
|
2021-09-01 03:17:38 +02:00
|
|
|
subprocess.check_call(
|
|
|
|
["git", "fetch", "--prune", "--quiet", "--tags", "--all"], preexec_fn=su_to_zulip
|
|
|
|
)
|
2021-05-06 21:49:07 +02:00
|
|
|
|
2021-05-13 21:53:04 +02:00
|
|
|
# Generate the deployment directory via git worktree from our local repository.
|
upgrade-zulip-from-git: Stop mirroring the remote.
The local `/srv/zulip.git` directory has been cloned with `--mirror`
since it was first created as a local cache in dc4b89fb085f. This
made some sense at the time, since it was purely a cache of the
remote, and not a home to local branches of its own.
That changed in 3f83b843c24a, when we began using `git worktree`,
which caused the `deployment-...` branches to begin being stored in
`/src/zulip.git`. This caused intermixing of local and remote
branches.
When 02582c695603 landed, the addition of `--prune` caused all but the
most recent deployment branch to be deleted upon every fetch --
leaving previous deployments with non-existent branches checked out:
```
zulip@example-prod-host:~/deployments/last$ git status
On branch deployment-2022-04-15-23-07-55
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .browserslistrc
new file: .codecov.yml
new file: .codespellignore
new file: .editorconfig
[...snip list of every file in repo...]
```
Switch `/srv/zulip.git` to no longer be a `--mirror` cache of the
origin. We reconfigure the remote to drop `remote.origin.mirror`, and
delete all refs under `refs/pulls/` and `refs/heads/`, while
preserving any checked-out branches. `refs/pulls/`, if the remote is
the canonical upstream, contains _tens of thousands_ of refs, so
pruning those refs trims off 20% of the repository size.
Those savings require a `git gc --prune=now`, otherwise the dangling
objects are ejected from the packfiles, which would balloon the
repository up to more than three times its previous size. Repacking
the repository is reasonable, in general, after removing such a large
number of refs -- and the `--prune=now` is safe and will not lose
data, as the `--mirror` was good at ensuring that the repository could
not be used for any local state.
The refname in the upgrade process was previously resolved from the
union of local and remote refs, since they were in the same namespace.
We instead now only resolve arguments as tags, then origin branches;
this means that stale local branches will be skipped. Users who want
to deploy from local branches can use `--remote-url=.`.
Because the `scripts/lib/upgrade-zulip-from-git` file is "stage 1" and
run from the old version's code, this will take two invocations of
`upgrade-zulip-from-git` to take effect.
Fixes #21901.
2022-05-12 22:45:18 +02:00
|
|
|
try:
|
|
|
|
fullref = f"refs/tags/{refname}"
|
|
|
|
commit_hash = subprocess.check_output(
|
|
|
|
["git", "rev-parse", "--verify", fullref],
|
|
|
|
preexec_fn=su_to_zulip,
|
|
|
|
text=True,
|
|
|
|
stderr=subprocess.DEVNULL,
|
|
|
|
).strip()
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
if e.returncode == 128:
|
|
|
|
# Try in the origin namespace
|
|
|
|
fullref = f"refs/remotes/origin/{refname}"
|
|
|
|
commit_hash = subprocess.check_output(
|
|
|
|
["git", "rev-parse", "--verify", fullref],
|
|
|
|
preexec_fn=su_to_zulip,
|
|
|
|
text=True,
|
|
|
|
stderr=subprocess.DEVNULL,
|
|
|
|
).strip()
|
|
|
|
refname = fullref
|
2022-02-16 20:55:29 +01:00
|
|
|
logging.info("Upgrading to %s, in %s", commit_hash, deploy_path)
|
2021-02-12 08:19:30 +01:00
|
|
|
subprocess.check_call(
|
2021-05-13 21:53:04 +02:00
|
|
|
["git", "worktree", "add", "--detach", deploy_path, refname],
|
|
|
|
stdout=subprocess.DEVNULL,
|
2021-02-12 08:19:30 +01:00
|
|
|
preexec_fn=su_to_zulip,
|
|
|
|
)
|
2018-11-07 02:12:31 +01:00
|
|
|
os.chdir(deploy_path)
|
upgrade-zulip-from-git: Stop mirroring the remote.
The local `/srv/zulip.git` directory has been cloned with `--mirror`
since it was first created as a local cache in dc4b89fb085f. This
made some sense at the time, since it was purely a cache of the
remote, and not a home to local branches of its own.
That changed in 3f83b843c24a, when we began using `git worktree`,
which caused the `deployment-...` branches to begin being stored in
`/src/zulip.git`. This caused intermixing of local and remote
branches.
When 02582c695603 landed, the addition of `--prune` caused all but the
most recent deployment branch to be deleted upon every fetch --
leaving previous deployments with non-existent branches checked out:
```
zulip@example-prod-host:~/deployments/last$ git status
On branch deployment-2022-04-15-23-07-55
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .browserslistrc
new file: .codecov.yml
new file: .codespellignore
new file: .editorconfig
[...snip list of every file in repo...]
```
Switch `/srv/zulip.git` to no longer be a `--mirror` cache of the
origin. We reconfigure the remote to drop `remote.origin.mirror`, and
delete all refs under `refs/pulls/` and `refs/heads/`, while
preserving any checked-out branches. `refs/pulls/`, if the remote is
the canonical upstream, contains _tens of thousands_ of refs, so
pruning those refs trims off 20% of the repository size.
Those savings require a `git gc --prune=now`, otherwise the dangling
objects are ejected from the packfiles, which would balloon the
repository up to more than three times its previous size. Repacking
the repository is reasonable, in general, after removing such a large
number of refs -- and the `--prune=now` is safe and will not lose
data, as the `--mirror` was good at ensuring that the repository could
not be used for any local state.
The refname in the upgrade process was previously resolved from the
union of local and remote refs, since they were in the same namespace.
We instead now only resolve arguments as tags, then origin branches;
this means that stale local branches will be skipped. Users who want
to deploy from local branches can use `--remote-url=.`.
Because the `scripts/lib/upgrade-zulip-from-git` file is "stage 1" and
run from the old version's code, this will take two invocations of
`upgrade-zulip-from-git` to take effect.
Fixes #21901.
2022-05-12 22:45:18 +02:00
|
|
|
extra_flags = []
|
|
|
|
if not refname.startswith("refs/tags/"):
|
|
|
|
extra_flags = ["-t"]
|
2021-05-13 21:53:04 +02:00
|
|
|
subprocess.check_call(
|
upgrade-zulip-from-git: Stop mirroring the remote.
The local `/srv/zulip.git` directory has been cloned with `--mirror`
since it was first created as a local cache in dc4b89fb085f. This
made some sense at the time, since it was purely a cache of the
remote, and not a home to local branches of its own.
That changed in 3f83b843c24a, when we began using `git worktree`,
which caused the `deployment-...` branches to begin being stored in
`/src/zulip.git`. This caused intermixing of local and remote
branches.
When 02582c695603 landed, the addition of `--prune` caused all but the
most recent deployment branch to be deleted upon every fetch --
leaving previous deployments with non-existent branches checked out:
```
zulip@example-prod-host:~/deployments/last$ git status
On branch deployment-2022-04-15-23-07-55
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .browserslistrc
new file: .codecov.yml
new file: .codespellignore
new file: .editorconfig
[...snip list of every file in repo...]
```
Switch `/srv/zulip.git` to no longer be a `--mirror` cache of the
origin. We reconfigure the remote to drop `remote.origin.mirror`, and
delete all refs under `refs/pulls/` and `refs/heads/`, while
preserving any checked-out branches. `refs/pulls/`, if the remote is
the canonical upstream, contains _tens of thousands_ of refs, so
pruning those refs trims off 20% of the repository size.
Those savings require a `git gc --prune=now`, otherwise the dangling
objects are ejected from the packfiles, which would balloon the
repository up to more than three times its previous size. Repacking
the repository is reasonable, in general, after removing such a large
number of refs -- and the `--prune=now` is safe and will not lose
data, as the `--mirror` was good at ensuring that the repository could
not be used for any local state.
The refname in the upgrade process was previously resolved from the
union of local and remote refs, since they were in the same namespace.
We instead now only resolve arguments as tags, then origin branches;
this means that stale local branches will be skipped. Users who want
to deploy from local branches can use `--remote-url=.`.
Because the `scripts/lib/upgrade-zulip-from-git` file is "stage 1" and
run from the old version's code, this will take two invocations of
`upgrade-zulip-from-git` to take effect.
Fixes #21901.
2022-05-12 22:45:18 +02:00
|
|
|
[
|
|
|
|
"git",
|
|
|
|
"checkout",
|
|
|
|
"-q",
|
|
|
|
*extra_flags,
|
|
|
|
"-b",
|
|
|
|
"deployment-" + os.path.basename(deploy_path),
|
|
|
|
refname,
|
|
|
|
],
|
2021-05-13 21:53:04 +02:00
|
|
|
preexec_fn=su_to_zulip,
|
|
|
|
)
|
2018-11-07 02:12:31 +01:00
|
|
|
|
2018-07-18 23:50:15 +02:00
|
|
|
overwrite_symlink("/etc/zulip/settings.py", "zproject/prod_settings.py")
|
2018-11-07 02:12:31 +01:00
|
|
|
|
2018-07-18 23:50:15 +02:00
|
|
|
overwrite_symlink(deploy_path, os.path.join(DEPLOYMENTS_DIR, "next"))
|
2018-11-07 02:12:31 +01:00
|
|
|
|
2021-04-21 03:26:33 +02:00
|
|
|
try:
|
|
|
|
subprocess.check_call(
|
|
|
|
[
|
|
|
|
os.path.join(deploy_path, "scripts", "lib", "upgrade-zulip-stage-2"),
|
|
|
|
deploy_path,
|
|
|
|
"--from-git",
|
|
|
|
*deploy_options,
|
2021-12-11 00:46:51 +01:00
|
|
|
*extra_options,
|
2021-04-21 03:26:33 +02:00
|
|
|
]
|
|
|
|
)
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
# There's no use in showing a stacktrace here; it just hides
|
|
|
|
# the error from stage 2.
|
|
|
|
sys.exit(1)
|
2018-11-07 02:12:31 +01:00
|
|
|
finally:
|
|
|
|
release_deployment_lock()
|