# 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. Make the web folder writable The dashboard publishes straight into the portal docroot `/var/www/trade/` (owner decision 2026-08-03) — it adds exactly three files there: `dashboard.html`, `snapshot.json`, `news.json`. The daemon user must be able to write them: ```bash # if the portal files can be owned by the daemon user: sudo chown Forex: /var/www/trade # otherwise grant write without changing ownership: sudo setfacl -m u:Forex:rwx /var/www/trade ``` (A different path is one edit away: 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 ``` ## 3. Smoke-test once ```bash venv/bin/python dashboard_publisher.py --once ls /var/www/trade # dashboard.html snapshot.json news.json added next to the portal ``` Then open `http:///dashboard.html` (path relative to however the vhost maps `/var/www/trade`) — 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=`), so no Apache config is strictly needed. To be explicit anyway: ```apache Header set Cache-Control "no-cache" ``` 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).