0445a20a76
Claude-Session: https://claude.ai/code/session_01Wc9ZoqKLYBT2QJcpRWKoGm
97 lines
3.4 KiB
Markdown
97 lines
3.4 KiB
Markdown
# Deploying the web dashboard (live LAMP server)
|
|
|
|
The dashboard is a **static publisher**: `dashboard_publisher.py` runs as its
|
|
own daemon, scans XAU/USD at candle closes, and atomically writes
|
|
`dashboard.html` + `snapshot.json` + `news.json` into a folder Apache already
|
|
serves. Apache does all web serving — no new port, no Python web server, and
|
|
the telegram bot process is completely unaffected by anything that happens
|
|
here (see the module docstring for the independence rules).
|
|
|
|
All steps below run **on the live server** (`/home/Forex/ForexBot2`).
|
|
|
|
## 1. Get the code
|
|
|
|
```bash
|
|
cd /home/Forex/ForexBot2
|
|
git pull
|
|
venv/bin/python test_all.py # optional sanity: suite must be green
|
|
```
|
|
|
|
No new Python dependencies are required.
|
|
|
|
## 2. Create the web folder
|
|
|
|
The portal docroot on this server is `/var/www/trade/`; the dashboard gets its
|
|
own subfolder so its three files never mix with the portal's:
|
|
|
|
```bash
|
|
sudo mkdir -p /var/www/trade/gold-dashboard
|
|
sudo chown Forex: /var/www/trade/gold-dashboard # the user the daemon runs as
|
|
```
|
|
|
|
(Any other path works too — set it in the unit's `Environment=DASHBOARD_OUT_DIR=`
|
|
line, or `--out` for one-off runs.)
|
|
|
|
SELinux (RHEL/Alma/CentOS enforcing): directories under `/var/www` normally
|
|
already carry `httpd_sys_content_t`, and new files inherit the parent label, so
|
|
no action is usually needed. If Apache 403s despite correct permissions:
|
|
|
|
```bash
|
|
sudo restorecon -R /var/www/trade/gold-dashboard
|
|
```
|
|
|
|
## 3. Smoke-test once
|
|
|
|
```bash
|
|
venv/bin/python dashboard_publisher.py --once
|
|
ls /var/www/trade/gold-dashboard # dashboard.html snapshot.json news.json
|
|
```
|
|
|
|
Then open `http://<server>/gold-dashboard/dashboard.html` — all four
|
|
timeframe cards, the calendar, and the newswire should populate.
|
|
|
|
## 4. Install the daemon
|
|
|
|
```bash
|
|
sudo cp deploy/gold-dashboard.service /etc/systemd/system/
|
|
# edit User= if the repo owner is not "Forex"
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable --now gold-dashboard
|
|
systemctl status gold-dashboard
|
|
tail -f logs/dashboard.log
|
|
```
|
|
|
|
The daemon scans all four timeframes at boot, then wakes at every M5
|
|
boundary (+10 s) and rescans whichever timeframes just closed. Logs rotate
|
|
every 3 h (240 backups), same scheme as the bot.
|
|
|
|
## 5. Optional Apache polish
|
|
|
|
The page cache-busts its JSON fetches (`?t=<epoch>`), so no Apache config is
|
|
strictly needed. To be explicit anyway:
|
|
|
|
```apache
|
|
<Directory "/var/www/trade/gold-dashboard">
|
|
<FilesMatch "\.json$">
|
|
Header set Cache-Control "no-cache"
|
|
</FilesMatch>
|
|
</Directory>
|
|
```
|
|
|
|
The page is deliberately public (owner decision 2026-08-03). To restrict it
|
|
later, add standard Apache basic auth (`htpasswd` + `Require valid-user`) on
|
|
that directory — no code changes needed.
|
|
|
|
## Operational notes
|
|
|
|
- **Updating**: `git pull` + `systemctl restart gold-dashboard`. The daemon
|
|
re-copies `static/dashboard.html` into the web folder at startup.
|
|
- **If the daemon dies**, systemd restarts it in 30 s; worst case the page
|
|
shows stale data with its own "updated N min ago" evidence. Apache and the
|
|
telegram bot are unaffected.
|
|
- **DeepSeek**: the publisher process has its own daily request cap
|
|
(`deepseek.daily_request_cap`, default 500) separate from the bot's —
|
|
expect roughly up to ~430 extra calls/day worst case, V4-Flash pricing.
|
|
- **Credentials**: uses the same env/.env/config.json resolution as the rest
|
|
of the platform (Oanda candles feed; news needs no key; DeepSeek optional).
|