144 lines
7.2 KiB
Markdown
144 lines
7.2 KiB
Markdown
# Live AWS deployment
|
|
|
|
Deployed September 13, 2026 to `ubuntu@34.228.59.242` using the supplied PPK key.
|
|
The server identifies itself as `ip-172-31-20-183`. Its timezone remains UTC.
|
|
|
|
| | Current version | V2 |
|
|
| --- | --- | --- |
|
|
| URL | https://workouttv.vitalityfitnessva.com | https://workouttv2.vitalityfitnessva.com |
|
|
| Service | `vitfit.service` | `vitfit-v2.service` |
|
|
| App | `/home/ubuntu/site` | `/home/ubuntu/vitfit-v2/app` |
|
|
| Node | Existing `/usr/bin/node` (18.19.1), unchanged | Separate `/home/ubuntu/vitfit-v2/runtime/bin/node` (24.21.0) |
|
|
| Port | Existing 3000 | `127.0.0.1:3001` |
|
|
| Database | `/home/ubuntu/site/database.sqlite` | `/home/ubuntu/vitfit-v2/data/vitfit.sqlite` |
|
|
| Uploads | `/home/ubuntu/site/public/uploads`, unchanged | `/home/ubuntu/vitfit-v2/data/uploads`, separate copies |
|
|
|
|
No Docker installation or server backup was made. V1 was never restarted during
|
|
deployment. Its Node installation, app code, database and original uploads were
|
|
left intact. Its Nginx configuration now uses Let's Encrypt and permits ACME
|
|
validation requests; its old certificate and private-key files remain in place.
|
|
|
|
## Login and data
|
|
|
|
Use existing V1 usernames/passwords on V2. The initial sync imported all 5 V1
|
|
accounts, 27 standard workouts, 192 video records and their referenced files,
|
|
plus 6 supporting categories. V1 has no Crossfit workouts currently; future
|
|
Crossfit workouts will sync. The existing V1 timer was not imported.
|
|
|
|
V1 `Admin` maps to V2 `Owner`; V1 `Coach` maps to V2 `Coach`. Imported usernames,
|
|
passwords, roles, active status, workout contents and video metadata are
|
|
authoritative in V1 and overwrite edits to those fields in V2 on the next sync.
|
|
Other V2 account profile fields, settings, branding, client data and V2-only
|
|
records remain local to V2. No data goes back to V1.
|
|
|
|
Exception: `jalleman` (V1 user ID 1, V2 user ID 2) is a V2 `SystemAdmin` at the
|
|
owner's request. `user_role_overrides` in `aws-sync.json` preserves this role
|
|
across daily syncs. The account retains its home organization and existing
|
|
password; password changes continue to sync from V1. V1's role is unchanged.
|
|
|
|
A separate `v2-system-admin` account exists for V2 system administration. Its
|
|
generated password is stored only on the server in
|
|
`/home/ubuntu/vitfit-v2/system-admin-credentials.json` (mode 0600, owned by ubuntu).
|
|
No generated password or JWT secret is included in this repository or deployment
|
|
output. The imported Admin accounts can administer their V2 organization without
|
|
using this separate account.
|
|
|
|
## Daily sync
|
|
|
|
`/etc/cron.d/vitfit-v2-sync` checks hourly. The script runs the actual sync once
|
|
at **05:00 America/New_York**, automatically following daylight saving time.
|
|
The server stays on UTC. A successful manual sync also marks that local day as
|
|
complete; a failed run does not mark it complete. A failed scheduled attempt
|
|
requires manual retry or waits until the next day's scheduled hour.
|
|
|
|
- Script: `/home/ubuntu/vitfit-v2/deploy/coexist/sync.py`
|
|
- Configuration: `/home/ubuntu/vitfit-v2/deploy/coexist/aws-sync.json`
|
|
- Log: `/var/log/vitfit-v2-sync.log`, weekly rotation, 8 rotations retained
|
|
- Last success: `/home/ubuntu/vitfit-v2/sync-state/last-success.json`
|
|
- Lock: `/home/ubuntu/vitfit-v2/sync-state/sync.lock`
|
|
|
|
`retain_snapshots` is **false**. SQLite's online backup API creates temporary
|
|
database working copies for a consistent source read and merge validation;
|
|
normal completion or an exception removes those copies. There is no retained
|
|
database backup or full-server backup. The last-success file contains counts
|
|
and timestamps only. As with other temporary files, a forced process kill or
|
|
power loss can leave interrupted working files; check `sync-state` after one.
|
|
|
|
Original videos never move, rename or change. Referenced videos are copied into
|
|
V2 under separate content-based filenames. Only 192 of the original directory's
|
|
263 entries are referenced by V1's video table, so the initial V2 copy is about
|
|
1.7 GiB. Old copied versions are retained; V2 never deletes original V1 files.
|
|
Monitor storage growth. The sync stages one source video library while running.
|
|
|
|
Deleted V1 accounts are disabled in V2. Deleted imported workouts are removed.
|
|
Deleted video metadata is retained if a V2 workout/client assignment still uses
|
|
it; the sync report names this count `Videos.retained_referenced`. Categories are
|
|
added without deleting categories needed by V2-only content.
|
|
|
|
Manual dry run and manual sync (run as ubuntu, never root):
|
|
|
|
```bash
|
|
cd /home/ubuntu/vitfit-v2/deploy/coexist
|
|
python3 sync.py --config aws-sync.json
|
|
python3 sync.py --config aws-sync.json --apply
|
|
```
|
|
|
|
Neither command moves original uploads or retains database working copies under
|
|
the installed configuration. The operation only updates mapped V2 records and
|
|
copies referenced media. Avoid editing imported videos in V2 while sync runs.
|
|
|
|
## HTTPS and renewal
|
|
|
|
Separate Let's Encrypt certificates are installed for both domain names under
|
|
`/etc/letsencrypt/live/<domain>/`. Their initial expiry is December 12, 2026.
|
|
Certbot is installed through snap. `snap.certbot.renew.timer` is enabled, and
|
|
`/etc/letsencrypt/renewal-hooks/deploy/20-vitfit-nginx` tests and reloads Nginx after
|
|
renewal. The certificates use webroot validation at `/var/www/letsencrypt`.
|
|
Keep inbound port 80 reachable for renewal, along with port 443 for the sites.
|
|
|
|
Certbot was registered without an email address because none was supplied.
|
|
An operational email can be added later with
|
|
`sudo /snap/bin/certbot update_account --email YOUR_EMAIL`.
|
|
|
|
Renewal test:
|
|
|
|
```bash
|
|
sudo /snap/bin/certbot renew --dry-run --run-deploy-hooks --no-random-sleep-on-renew
|
|
```
|
|
|
|
Nginx uses the existing `/etc/nginx/sites-enabled/default` for V1 and
|
|
`/etc/nginx/sites-available/workouttv2.conf` for V2. The latter matches
|
|
`workouttv2-ssl.conf` in this folder. Do not replace it with the HTTP bootstrap
|
|
template after certificates have been installed.
|
|
|
|
## Verification completed
|
|
|
|
- All 14 backup/sync integration tests passed on both Windows and this Ubuntu
|
|
host against disposable databases built using the real V2 migrations.
|
|
- Both HTTPS sites returned successfully, and V2's database/disk health was OK.
|
|
- V2 SystemAdmin login, all 192 video file-existence checks, listing all 27
|
|
workouts, authenticated byte-range video streaming, and an authenticated
|
|
WebSocket connection through Nginx passed.
|
|
- Imported usernames/password hashes matched all 5 original accounts.
|
|
- Both certificate renewal simulations and Nginx deploy hooks succeeded.
|
|
- V1's database hash was unchanged. All 263 original upload entries retained
|
|
the same filenames, inodes, sizes and modification times.
|
|
- V1 kept PID 3428973 and its original service start time throughout deployment.
|
|
- No database working-copy directories remained after the first sync.
|
|
|
|
## Operations
|
|
|
|
```bash
|
|
systemctl status vitfit vitfit-v2
|
|
journalctl -u vitfit-v2 --since today
|
|
cat /home/ubuntu/vitfit-v2/sync-state/last-success.json
|
|
tail -n 50 /var/log/vitfit-v2-sync.log
|
|
systemctl list-timers --all | grep certbot
|
|
df -h /
|
|
```
|
|
|
|
To stop V2 temporarily, stop `vitfit-v2.service`. Disable its cron entry too if
|
|
V2 must receive no further data updates. V1 continues independently. There is no
|
|
automatic rollback backup, per the server constraint. Preserve the original V1
|
|
database and uploads as the authoritative source throughout the transition.
|