Skip to content

Commit 47cbdec

Browse files
authored
Enhance healthchecks update process with backup and venv
Added backup creation for existing healthchecks installation before updating. Enhanced the update process by recreating the Python virtual environment and installing requirements.
1 parent 7f28f12 commit 47cbdec

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

ct/healthchecks.sh

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,42 @@ function update_script() {
2828
msg_error "No ${APP} Installation Found!"
2929
exit
3030
fi
31+
3132
if check_for_gh_release "healthchecks" "healthchecks/healthchecks"; then
3233
msg_info "Stopping Services"
3334
systemctl stop healthchecks
3435
msg_ok "Stopped Services"
3536

36-
PYTHON_VERSION="3.13" setup_uv
37+
msg_info "Backing up existing installation"
38+
BACKUP="/opt/healthchecks-backup-$(date +%F-%H%M)"
39+
cp -a /opt/healthchecks "$BACKUP"
40+
msg_ok "Backup created at $BACKUP"
41+
3742
fetch_and_deploy_gh_release "healthchecks" "healthchecks/healthchecks"
3843

39-
msg_info "Updating healthchecks"
4044
cd /opt/healthchecks
41-
mkdir -p /opt/healthchecks/static-collected/
42-
$STD uv pip install wheel gunicorn -r requirements.txt --system
43-
$STD uv run -- python manage.py makemigrations
44-
$STD uv run -- python manage.py migrate --noinput
45-
$STD uv run -- python manage.py collectstatic --noinput
46-
$STD uv run -- python manage.py compress
47-
msg_ok "Updated healthchecks"
45+
if [[ -d venv ]]; then
46+
rm -rf venv
47+
fi
48+
msg_info "Recreating Python venv"
49+
$STD python3 -m venv venv
50+
$STD source venv/bin/activate
51+
$STD pip install --upgrade pip wheel
52+
msg_ok "Created venv"
53+
54+
msg_info "Installing requirements"
55+
$STD pip install gunicorn -r requirements.txt
56+
msg_ok "Installed requirements"
57+
58+
msg_info "Running Django migrations"
59+
$STD python manage.py migrate --noinput
60+
$STD python manage.py collectstatic --noinput
61+
$STD python manage.py compress
62+
msg_ok "Completed Django migrations and static build"
63+
4864
msg_info "Starting Services"
4965
systemctl start healthchecks
50-
systemctl restart caddy
66+
systemctl reload caddy
5167
msg_ok "Started Services"
5268
msg_ok "Updated successfully!"
5369
fi

0 commit comments

Comments
 (0)