Move host-specific deploy notes to local/bestmidi

This commit is contained in:
Jage9
2026-02-24 23:54:54 -05:00
parent 5c63e087b3
commit d1afca806a
3 changed files with 303 additions and 47 deletions

View File

@@ -40,8 +40,8 @@ Common server overrides:
Use `deploy/README.md`. Use `deploy/README.md`.
Summary: Summary:
1. Copy repo to `/home/bestmidi/chgrid`. 1. Copy repo to `/home/<user>/chgrid`.
2. Build client and publish `client/dist/` to `/home/bestmidi/public_html/chgrid/`. 2. Build client and publish `client/dist/` to `/home/<user>/public_html/chgrid/`.
3. Configure server `config.toml` and run it via `systemd`. 3. Configure server `config.toml` and run it via `systemd`.
4. Add Apache `/ws` websocket proxy from `deploy/apache/chgrid-vhost-snippet.conf`. 4. Add Apache `/ws` websocket proxy from `deploy/apache/chgrid-vhost-snippet.conf`.

View File

@@ -1,14 +1,14 @@
# Deployment Guide # Deployment Guide
Target example: AlmaLinux/cPanel host with files under `/home/bestmidi`. Target example: AlmaLinux/cPanel host with files under `/home/<user>`.
## 1) Place project files ## 1) Place project files
- Repo root: `/home/bestmidi/chgrid` - Repo root: `/home/<user>/chgrid`
## 2) Make deploy scripts executable (once) ## 2) Make deploy scripts executable (once)
```bash ```bash
cd /home/bestmidi/chgrid cd /home/<user>/chgrid
chmod +x deploy/scripts/*.sh chmod +x deploy/scripts/*.sh
``` ```
@@ -17,31 +17,31 @@ chmod +x deploy/scripts/*.sh
Verify server files first: Verify server files first:
```bash ```bash
ls -l /home/bestmidi/chgrid/server/pyproject.toml ls -l /home/<user>/chgrid/server/pyproject.toml
``` ```
Run install scripts from repo root (`/home/bestmidi/chgrid`), not from `server/`. Run install scripts from repo root (`/home/<user>/chgrid`), not from `server/`.
```bash ```bash
cd /home/bestmidi/chgrid cd /home/<user>/chgrid
./deploy/scripts/install_server.sh /home/bestmidi/chgrid ./deploy/scripts/install_server.sh /home/<user>/chgrid
``` ```
Notes: Notes:
- Script defaults to Python `3.13` (`PYTHON_SPEC=3.13`). - Script defaults to Python `3.13` (`PYTHON_SPEC=3.13`).
- It reuses existing `.venv` instead of replacing it interactively. - It reuses existing `.venv` instead of replacing it interactively.
- If you need to force a fresh 3.13 env: - If you need to force a fresh 3.13 env:
- `rm -rf /home/bestmidi/chgrid/server/.venv` - `rm -rf /home/<user>/chgrid/server/.venv`
- rerun `./deploy/scripts/install_server.sh /home/bestmidi/chgrid` - rerun `./deploy/scripts/install_server.sh /home/<user>/chgrid`
This creates: This creates:
- `/home/bestmidi/chgrid/server/.venv` - `/home/<user>/chgrid/server/.venv`
- `/home/bestmidi/chgrid/server/config.toml` (if missing) - `/home/<user>/chgrid/server/config.toml` (if missing)
- `/home/bestmidi/chgrid/server/.env` with `CHGRID_AUTH_SECRET` (if missing) - `/home/<user>/chgrid/server/.env` with `CHGRID_AUTH_SECRET` (if missing)
- `/home/bestmidi/chgrid/server/run_server.sh` (loads `.env` then starts server) - `/home/<user>/chgrid/server/run_server.sh` (loads `.env` then starts server)
- On first run only, if no admin exists, it prompts to create one immediately. - On first run only, if no admin exists, it prompts to create one immediately.
Edit `/home/bestmidi/chgrid/server/config.toml`: Edit `/home/<user>/chgrid/server/config.toml`:
- `server.bind_ip = "127.0.0.1"` - `server.bind_ip = "127.0.0.1"`
- `server.port = 8765` - `server.port = 8765`
- `network.allow_insecure_ws = true` - `network.allow_insecure_ws = true`
@@ -53,7 +53,7 @@ Edit `/home/bestmidi/chgrid/server/config.toml`:
If you skip first-run admin creation, run later: If you skip first-run admin creation, run later:
```bash ```bash
cd /home/bestmidi/chgrid/server cd /home/<user>/chgrid/server
source .env source .env
.venv/bin/python main.py --config config.toml --bootstrap-admin .venv/bin/python main.py --config config.toml --bootstrap-admin
``` ```
@@ -61,14 +61,14 @@ source .env
## 4) Build and publish client ## 4) Build and publish client
```bash ```bash
cd /home/bestmidi/chgrid cd /home/<user>/chgrid
./deploy/scripts/deploy_client.sh /home/bestmidi/chgrid /home/bestmidi/public_html/chgrid /chgrid/ ./deploy/scripts/deploy_client.sh /home/<user>/chgrid /home/<user>/public_html/chgrid /chgrid/
``` ```
Notes: Notes:
- Third arg is Vite base path for production assets. - Third arg is Vite base path for production assets.
- For `https://bestmidi.com/chgrid/`, use `/chgrid/`. - For `https://example.com/chgrid/`, use `/chgrid/`.
- For site root deploy (`https://bestmidi.com/`), use `/`. - For site root deploy (`https://example.com/`), use `/`.
- Deploy script normalizes publish permissions to avoid shared-host PHP soft exceptions: - Deploy script normalizes publish permissions to avoid shared-host PHP soft exceptions:
- directories `755` - directories `755`
- files `644` - files `644`
@@ -76,26 +76,26 @@ Notes:
Shortcut (client deploy + service restart): Shortcut (client deploy + service restart):
```bash ```bash
cd /home/bestmidi/chgrid cd /home/<user>/chgrid
./deploy/scripts/up.sh /home/bestmidi/chgrid /home/bestmidi/public_html/chgrid /chgrid/ ./deploy/scripts/up.sh /home/<user>/chgrid /home/<user>/public_html/chgrid /chgrid/
``` ```
## 5) Install/restart signaling service (systemd) ## 5) Install/restart signaling service (systemd)
```bash ```bash
cd /home/bestmidi/chgrid cd /home/<user>/chgrid
./deploy/scripts/install_service.sh /home/bestmidi/chgrid ./deploy/scripts/install_service.sh /home/<user>/chgrid
``` ```
Notes: Notes:
- Service startup uses `/home/bestmidi/chgrid/server/run_server.sh`, which sources local - Service startup uses `/home/<user>/chgrid/server/run_server.sh`, which sources local
`/home/bestmidi/chgrid/server/.env` before launching Python. `/home/<user>/chgrid/server/.env` before launching Python.
Logs: Logs:
```bash ```bash
journalctl -u chat-grid.service -f journalctl -u chat-grid.service -f
tail -f /home/bestmidi/chgrid/server/runtime/server.log tail -f /home/<user>/chgrid/server/runtime/server.log
``` ```
If you previously used `chgrid-signaling.service`, migrate once: If you previously used `chgrid-signaling.service`, migrate once:
@@ -110,10 +110,10 @@ sudo systemctl daemon-reload
Install using script: Install using script:
```bash ```bash
cd /home/bestmidi/chgrid cd /home/<user>/chgrid
./deploy/scripts/install_apache.sh \ ./deploy/scripts/install_apache.sh \
/home/bestmidi/chgrid \ /home/<user>/chgrid \
/etc/apache2/conf.d/userdata/ssl/2_4/bestmidi/yourdomain.com/chgrid.conf /etc/apache2/conf.d/userdata/ssl/2_4/<cpanel-user>/yourdomain.com/chgrid.conf
``` ```
Notes: Notes:
@@ -127,7 +127,7 @@ Notes:
If stream sources are plain HTTP (for example ports `8000`, `8010`, `8020`, `8030`), add relays in: If stream sources are plain HTTP (for example ports `8000`, `8010`, `8020`, `8030`), add relays in:
`/etc/apache2/conf.d/userdata/ssl/2_4/bestmidi/bestmidi.com/chgrid.conf` `/etc/apache2/conf.d/userdata/ssl/2_4/<cpanel-user>/example.com/chgrid.conf`
Example: Example:
@@ -150,7 +150,7 @@ sudo /usr/local/cpanel/scripts/restartsrv_httpd
``` ```
Usage example in Chat Grid: Usage example in Chat Grid:
- `https://bestmidi.com/listen/8000/stream` - `https://example.com/listen/8000/stream`
## 8) PHP media proxy (Dropbox + HTTP stream passthrough) ## 8) PHP media proxy (Dropbox + HTTP stream passthrough)
@@ -158,26 +158,26 @@ Usage example in Chat Grid:
It is auto-copied to your publish dir by `deploy_client.sh` (and `up.sh`), so after deploy it should be available at: It is auto-copied to your publish dir by `deploy_client.sh` (and `up.sh`), so after deploy it should be available at:
- `https://bestmidi.com/chgrid/media_proxy.php` - `https://example.com/chgrid/media_proxy.php`
Use in Chat Grid `streamUrl`: Use in Chat Grid `streamUrl`:
```text ```text
https://bestmidi.com/chgrid/media_proxy.php?url=<urlencoded-upstream-url> https://example.com/chgrid/media_proxy.php?url=<urlencoded-upstream-url>
``` ```
Examples: Examples:
- Dropbox: - Dropbox:
`https://bestmidi.com/chgrid/media_proxy.php?url=https%3A%2F%2Fwww.dropbox.com%2Fscl%2Ffi%2Fa7s3n15bgj043rr54k3n9%2FMario-Hold-Music.mp3%3Frlkey%3Ddfr3dybr7s7nndudag0k8xflc%26dl%3D1` `https://example.com/chgrid/media_proxy.php?url=https%3A%2F%2Fwww.dropbox.com%2Fscl%2Ffi%2Fa7s3n15bgj043rr54k3n9%2FMario-Hold-Music.mp3%3Frlkey%3Ddfr3dybr7s7nndudag0k8xflc%26dl%3D1`
- HTTP stream: - HTTP stream:
`https://bestmidi.com/chgrid/media_proxy.php?url=http%3A%2F%2Fstream.rpgamers.net%3A8000%2Frpgn` `https://example.com/chgrid/media_proxy.php?url=http%3A%2F%2Fstream.rpgamers.net%3A8000%2Frpgn`
Troubleshooting checks: Troubleshooting checks:
```bash ```bash
curl -I "https://bestmidi.com/chgrid/media_proxy.php?url=https%3A%2F%2Fwww.dropbox.com%2Fscl%2Ffi%2Fa7s3n15bgj043rr54k3n9%2FMario-Hold-Music.mp3%3Frlkey%3Ddfr3dybr7s7nndudag0k8xflc%26dl%3D1" curl -I "https://example.com/chgrid/media_proxy.php?url=https%3A%2F%2Fwww.dropbox.com%2Fscl%2Ffi%2Fa7s3n15bgj043rr54k3n9%2FMario-Hold-Music.mp3%3Frlkey%3Ddfr3dybr7s7nndudag0k8xflc%26dl%3D1"
curl -I "https://bestmidi.com/chgrid/media_proxy.php?url=http%3A%2F%2Fstream.rpgamers.net%3A8000%2Frpgn" curl -I "https://example.com/chgrid/media_proxy.php?url=http%3A%2F%2Fstream.rpgamers.net%3A8000%2Frpgn"
``` ```
Optional hardening: Optional hardening:
@@ -185,28 +185,28 @@ Optional hardening:
- Set env var `CHGRID_MEDIA_PROXY_ALLOWLIST` (comma-separated hosts/suffixes) in Apache/PHP-FPM. - Set env var `CHGRID_MEDIA_PROXY_ALLOWLIST` (comma-separated hosts/suffixes) in Apache/PHP-FPM.
- Example: `dropbox.com,dropboxusercontent.com,stream.rpgamers.net` - Example: `dropbox.com,dropboxusercontent.com,stream.rpgamers.net`
## 9) GitHub-based update flow (`bestmidi`) ## 9) GitHub-based update flow
Initial clone (one time): Initial clone (one time):
```bash ```bash
cd /home/bestmidi cd /home/<user>
git clone https://github.com/jage9/chat_grid.git chgrid git clone https://github.com/jage9/chat_grid.git chgrid
``` ```
Update and redeploy: Update and redeploy:
```bash ```bash
cd /home/bestmidi/chgrid cd /home/<user>/chgrid
git fetch origin git fetch origin
git switch main git switch main
git pull --ff-only origin main git pull --ff-only origin main
# Rebuild/publish web client # Rebuild/publish web client
./deploy/scripts/deploy_client.sh /home/bestmidi/chgrid /home/bestmidi/public_html/chgrid /chgrid/ ./deploy/scripts/deploy_client.sh /home/<user>/chgrid /home/<user>/public_html/chgrid /chgrid/
# Reconcile server env/deps (safe to rerun on updates) # Reconcile server env/deps (safe to rerun on updates)
./deploy/scripts/install_server.sh /home/bestmidi/chgrid ./deploy/scripts/install_server.sh /home/<user>/chgrid
# Restart signaling service # Restart signaling service
sudo systemctl restart chat-grid.service sudo systemctl restart chat-grid.service
@@ -216,8 +216,8 @@ journalctl -u chat-grid.service -n 50 --no-pager
Typical quick update: Typical quick update:
```bash ```bash
cd /home/bestmidi/chgrid cd /home/<user>/chgrid
./deploy/scripts/up.sh /home/bestmidi/chgrid /home/bestmidi/public_html/chgrid /chgrid/ ./deploy/scripts/up.sh /home/<user>/chgrid /home/<user>/public_html/chgrid /chgrid/
``` ```
Notes: Notes:
@@ -245,7 +245,7 @@ Then run one authenticated command and enter:
- Password: your GitHub PAT - Password: your GitHub PAT
```bash ```bash
cd /home/bestmidi/chgrid cd /home/<user>/chgrid
git pull --ff-only origin main git pull --ff-only origin main
``` ```

256
local/bestmidi.md Normal file
View File

@@ -0,0 +1,256 @@
# Deployment Guide
Target example: AlmaLinux/cPanel host with files under `/home/bestmidi`.
## 1) Place project files
- Repo root: `/home/bestmidi/chgrid`
## 2) Make deploy scripts executable (once)
```bash
cd /home/bestmidi/chgrid
chmod +x deploy/scripts/*.sh
```
## 3) Install server (uv)
Verify server files first:
```bash
ls -l /home/bestmidi/chgrid/server/pyproject.toml
```
Run install scripts from repo root (`/home/bestmidi/chgrid`), not from `server/`.
```bash
cd /home/bestmidi/chgrid
./deploy/scripts/install_server.sh /home/bestmidi/chgrid
```
Notes:
- Script defaults to Python `3.13` (`PYTHON_SPEC=3.13`).
- It reuses existing `.venv` instead of replacing it interactively.
- If you need to force a fresh 3.13 env:
- `rm -rf /home/bestmidi/chgrid/server/.venv`
- rerun `./deploy/scripts/install_server.sh /home/bestmidi/chgrid`
This creates:
- `/home/bestmidi/chgrid/server/.venv`
- `/home/bestmidi/chgrid/server/config.toml` (if missing)
- `/home/bestmidi/chgrid/server/.env` with `CHGRID_AUTH_SECRET` (if missing)
- `/home/bestmidi/chgrid/server/run_server.sh` (loads `.env` then starts server)
- On first run only, if no admin exists, it prompts to create one immediately.
Edit `/home/bestmidi/chgrid/server/config.toml`:
- `server.bind_ip = "127.0.0.1"`
- `server.port = 8765`
- `network.allow_insecure_ws = true`
- `tls.cert_file = ""`
- `tls.key_file = ""`
- `storage.state_file = "runtime/items.json"`
- `auth.db_file = "runtime/chatgrid.db"`
If you skip first-run admin creation, run later:
```bash
cd /home/bestmidi/chgrid/server
source .env
.venv/bin/python main.py --config config.toml --bootstrap-admin
```
## 4) Build and publish client
```bash
cd /home/bestmidi/chgrid
./deploy/scripts/deploy_client.sh /home/bestmidi/chgrid /home/bestmidi/public_html/chgrid /chgrid/
```
Notes:
- Third arg is Vite base path for production assets.
- For `https://bestmidi.com/chgrid/`, use `/chgrid/`.
- For site root deploy (`https://bestmidi.com/`), use `/`.
- Deploy script normalizes publish permissions to avoid shared-host PHP soft exceptions:
- directories `755`
- files `644`
Shortcut (client deploy + service restart):
```bash
cd /home/bestmidi/chgrid
./deploy/scripts/up.sh /home/bestmidi/chgrid /home/bestmidi/public_html/chgrid /chgrid/
```
## 5) Install/restart signaling service (systemd)
```bash
cd /home/bestmidi/chgrid
./deploy/scripts/install_service.sh /home/bestmidi/chgrid
```
Notes:
- Service startup uses `/home/bestmidi/chgrid/server/run_server.sh`, which sources local
`/home/bestmidi/chgrid/server/.env` before launching Python.
Logs:
```bash
journalctl -u chat-grid.service -f
tail -f /home/bestmidi/chgrid/server/runtime/server.log
```
If you previously used `chgrid-signaling.service`, migrate once:
```bash
sudo systemctl disable --now chgrid-signaling.service
sudo systemctl daemon-reload
```
## 6) Apache websocket proxy
Install using script:
```bash
cd /home/bestmidi/chgrid
./deploy/scripts/install_apache.sh \
/home/bestmidi/chgrid \
/etc/apache2/conf.d/userdata/ssl/2_4/bestmidi/yourdomain.com/chgrid.conf
```
Notes:
- Replace `yourdomain.com` with your real domain.
- Script copies `deploy/apache/chgrid-vhost-snippet.conf`, runs `rebuildhttpdconf`, then restarts Apache via WHM restart command.
- Snippet now includes no-cache headers for `/chgrid/` and `/chgrid/index.html` so client updates are not stuck on stale HTML.
- `deploy_client.sh` also installs `/chgrid/.htaccess` from `deploy/apache/chgrid-public-htaccess`
to force no-cache on `index.html` and `version.js` in shared-host setups.
## 7) Optional HTTPS relay for HTTP radio streams
If stream sources are plain HTTP (for example ports `8000`, `8010`, `8020`, `8030`), add relays in:
`/etc/apache2/conf.d/userdata/ssl/2_4/bestmidi/bestmidi.com/chgrid.conf`
Example:
```apache
ProxyPass /listen/8000/ http://127.0.0.1:8000/
ProxyPassReverse /listen/8000/ http://127.0.0.1:8000/
ProxyPass /listen/8010/ http://127.0.0.1:8010/
ProxyPassReverse /listen/8010/ http://127.0.0.1:8010/
ProxyPass /listen/8020/ http://127.0.0.1:8020/
ProxyPassReverse /listen/8020/ http://127.0.0.1:8020/
ProxyPass /listen/8030/ http://127.0.0.1:8030/
ProxyPassReverse /listen/8030/ http://127.0.0.1:8030/
```
Apply changes:
```bash
sudo /usr/local/cpanel/scripts/rebuildhttpdconf
sudo /usr/local/cpanel/scripts/restartsrv_httpd
```
Usage example in Chat Grid:
- `https://bestmidi.com/listen/8000/stream`
## 8) PHP media proxy (Dropbox + HTTP stream passthrough)
`deploy/php/media_proxy.php` is a lightweight same-origin proxy for stream URLs.
It is auto-copied to your publish dir by `deploy_client.sh` (and `up.sh`), so after deploy it should be available at:
- `https://bestmidi.com/chgrid/media_proxy.php`
Use in Chat Grid `streamUrl`:
```text
https://bestmidi.com/chgrid/media_proxy.php?url=<urlencoded-upstream-url>
```
Examples:
- Dropbox:
`https://bestmidi.com/chgrid/media_proxy.php?url=https%3A%2F%2Fwww.dropbox.com%2Fscl%2Ffi%2Fa7s3n15bgj043rr54k3n9%2FMario-Hold-Music.mp3%3Frlkey%3Ddfr3dybr7s7nndudag0k8xflc%26dl%3D1`
- HTTP stream:
`https://bestmidi.com/chgrid/media_proxy.php?url=http%3A%2F%2Fstream.rpgamers.net%3A8000%2Frpgn`
Troubleshooting checks:
```bash
curl -I "https://bestmidi.com/chgrid/media_proxy.php?url=https%3A%2F%2Fwww.dropbox.com%2Fscl%2Ffi%2Fa7s3n15bgj043rr54k3n9%2FMario-Hold-Music.mp3%3Frlkey%3Ddfr3dybr7s7nndudag0k8xflc%26dl%3D1"
curl -I "https://bestmidi.com/chgrid/media_proxy.php?url=http%3A%2F%2Fstream.rpgamers.net%3A8000%2Frpgn"
```
Optional hardening:
- Set env var `CHGRID_MEDIA_PROXY_ALLOWLIST` (comma-separated hosts/suffixes) in Apache/PHP-FPM.
- Example: `dropbox.com,dropboxusercontent.com,stream.rpgamers.net`
## 9) GitHub-based update flow (`bestmidi`)
Initial clone (one time):
```bash
cd /home/bestmidi
git clone https://github.com/jage9/chat_grid.git chgrid
```
Update and redeploy:
```bash
cd /home/bestmidi/chgrid
git fetch origin
git switch main
git pull --ff-only origin main
# Rebuild/publish web client
./deploy/scripts/deploy_client.sh /home/bestmidi/chgrid /home/bestmidi/public_html/chgrid /chgrid/
# Reconcile server env/deps (safe to rerun on updates)
./deploy/scripts/install_server.sh /home/bestmidi/chgrid
# Restart signaling service
sudo systemctl restart chat-grid.service
journalctl -u chat-grid.service -n 50 --no-pager
```
Typical quick update:
```bash
cd /home/bestmidi/chgrid
./deploy/scripts/up.sh /home/bestmidi/chgrid /home/bestmidi/public_html/chgrid /chgrid/
```
Notes:
- Run Apache install/reload steps again only if proxy config changed.
- If your checkout has local changes, stash or commit before `git pull`.
- For HTTPS GitHub auth, use your GitHub username plus a Personal Access Token (PAT) as the password.
- SSH key passphrases are only used for `git@github.com:` remotes, not `https://` remotes.
## 10) Save GitHub PAT for HTTPS pulls/pushes
Persistent storage (simple, plaintext in `~/.git-credentials`):
```bash
git config --global credential.helper store
```
Memory cache only (not persisted across reboot):
```bash
git config --global credential.helper "cache --timeout=28800"
```
Then run one authenticated command and enter:
- Username: `jage9`
- Password: your GitHub PAT
```bash
cd /home/bestmidi/chgrid
git pull --ff-only origin main
```
If you saved the wrong token and need to re-enter it:
```bash
printf "protocol=https\nhost=github.com\n" | git credential reject
```