-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·38 lines (31 loc) · 1.1 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·38 lines (31 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
# Deploy buffettindicators to the VPS: sync the repo into /srv, install
# production deps, and restart the systemd service. Run from the repo root.
set -euo pipefail
SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DEST_DIR="/srv/buffettindicators"
SERVICE="buffettindicators.service"
HEALTH_URL="http://127.0.0.1:3002/"
cd "$SRC_DIR"
echo "==> sync to $DEST_DIR"
# Exclude local-only and generated files; never overwrite the live cache dir.
rsync -a --delete \
--exclude '.git/' \
--exclude 'node_modules/' \
--exclude '.env' \
--exclude '.env.local' \
--exclude '*.pem' \
--exclude 'data/' \
--exclude '*.db' --exclude '*.db-shm' --exclude '*.db-wal' \
"$SRC_DIR"/ "$DEST_DIR"/
echo "==> install production deps"
( cd "$DEST_DIR" && npm ci --omit=dev )
echo "==> restart $SERVICE"
sudo systemctl restart "$SERVICE"
sleep 1
sudo systemctl is-active "$SERVICE" >/dev/null && echo "==> active"
if curl -fsS -o /dev/null -w '%{http_code}\n' "$HEALTH_URL" | grep -q '^200$'; then
echo "==> $HEALTH_URL 200 OK"
else
echo "==> warning: health check did not return 200" >&2
fi