chore(deploy): keep start scripts and systemd units in deploy/

The three services become quant-trading-monitor, quant-trading-api and
quant-trading-vite, run from /home/gahow/projects/quant-trading. Their
units were previously untracked files in ~/.config/systemd/user.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-25 11:42:40 +08:00
parent 96a845ebcd
commit 83495bcd23
8 changed files with 90 additions and 26 deletions

23
deploy/start-monitor.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Long-running live-trader monitor (US + CN, all strategies).
# Started by the quant-trading-monitor.service systemd --user unit; replaces the
# old "tmux new -s quant; uv run python trader.py monitor" workflow.
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT="$( cd "$SCRIPT_DIR/.." && pwd )"
cd "$PROJECT_ROOT"
# uv lives in ~/.local/bin, which is not on systemd's default PATH.
export PATH="/home/gahow/.local/bin:$PATH"
# Market data is fetched through the lab proxy (same as interactive `proxyOn`).
# QUANT_MARKET_PROXY lives in the untracked repo-root .env.
if [[ -f .env ]]; then
set -a; source .env; set +a
fi
if [[ -n "${QUANT_MARKET_PROXY:-}" ]]; then
export http_proxy="$QUANT_MARKET_PROXY" https_proxy="$QUANT_MARKET_PROXY" all_proxy="$QUANT_MARKET_PROXY"
fi
exec uv run python trader.py monitor

14
deploy/start-web-api.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../web" && pwd)"
cd "${ROOT_DIR}"
export PATH="/home/gahow/.local/bin:/home/gahow/.nvm/versions/node/v24.13.1/bin:$PATH"
export HOST="127.0.0.1"
export PORT="${PORT:-8787}"
# Node's built-in fetch does not read HTTPS_PROXY unless this opt-in is enabled.
# The configured Nasdaq/Yahoo data sources require the host's local proxy.
export NODE_USE_ENV_PROXY="${NODE_USE_ENV_PROXY:-1}"
exec npx tsx src/server/index.ts

11
deploy/start-web-vite.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../web" && pwd)"
cd "${ROOT_DIR}"
export PATH="/home/gahow/.nvm/versions/node/v24.13.1/bin:$PATH"
# The public HTTPS entrypoint is nginx on :5443. Keep Vite as a localhost-only
# upstream so the development server is not exposed as a second LAN entrypoint.
exec npx vite --host 127.0.0.1 --port 5174

View File

@@ -0,0 +1,14 @@
[Unit]
Description=Quant trading web API server
After=network-online.target
[Service]
Type=simple
WorkingDirectory=/home/gahow/projects/quant-trading/web
ExecStart=/home/gahow/projects/quant-trading/deploy/start-web-api.sh
Restart=always
RestartSec=3
Environment=NODE_ENV=production
[Install]
WantedBy=default.target

View File

@@ -0,0 +1,14 @@
[Unit]
Description=Quant live trader monitor (US + CN, all strategies)
After=network-online.target
[Service]
Type=simple
WorkingDirectory=/home/gahow/projects/quant-trading
ExecStart=/home/gahow/projects/quant-trading/deploy/start-monitor.sh
Restart=always
RestartSec=10
Environment=PYTHONUNBUFFERED=1
[Install]
WantedBy=default.target

View File

@@ -0,0 +1,13 @@
[Unit]
Description=Quant trading web frontend (Vite dev server behind nginx)
After=network-online.target
[Service]
Type=simple
WorkingDirectory=/home/gahow/projects/quant-trading/web
ExecStart=/home/gahow/projects/quant-trading/deploy/start-web-vite.sh
Restart=always
RestartSec=3
[Install]
WantedBy=default.target