Initial eth_hedge_sim: P0 market, auth UI, one-click deploy.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
# 首次安装到 /opt/eth_hedge_sim(仅 git clone,后续一律 git pull)
|
||||
set -euo pipefail
|
||||
|
||||
REPO_URL="${REPO_URL:-https://git.bz121.com/dekun/eth_hedge_sim.git}"
|
||||
ROOT="${INSTALL_ROOT:-/opt/eth_hedge_sim}"
|
||||
|
||||
if [[ ! -d "$ROOT/.git" ]]; then
|
||||
mkdir -p "$(dirname "$ROOT")"
|
||||
git clone "$REPO_URL" "$ROOT"
|
||||
fi
|
||||
|
||||
bash "$ROOT/deploy/pull_and_restart.sh"
|
||||
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'eth-hedge-api',
|
||||
cwd: '/opt/eth_hedge_sim/backend',
|
||||
script: '/opt/eth_hedge_sim/.venv/bin/uvicorn',
|
||||
args: 'app.main:app --host 0.0.0.0 --port 5155',
|
||||
interpreter: 'none',
|
||||
env: {
|
||||
MODE: 'SIM',
|
||||
ENV_NAME: 'test',
|
||||
TZ: 'Asia/Shanghai',
|
||||
},
|
||||
// 密钥与本地配置一律读 /opt/eth_hedge_sim/.env(勿写进本文件)
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
# 一键更新/部署:仅 git pull,禁止 scp 传代码。
|
||||
# 用法(服务器上): bash /opt/eth_hedge_sim/deploy/pull_and_restart.sh
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
echo "[eth_hedge_sim] pull @ $ROOT"
|
||||
git fetch --all --prune
|
||||
git pull --ff-only
|
||||
|
||||
if [[ ! -f "$ROOT/.env" ]]; then
|
||||
echo "[eth_hedge_sim] missing .env — copy from example"
|
||||
cp "$ROOT/.env.example" "$ROOT/.env"
|
||||
# 云上测试机默认直连 OKX
|
||||
sed -i 's/^OKX_HTTP_PROXY=.*/OKX_HTTP_PROXY=/' "$ROOT/.env" || true
|
||||
sed -i 's/^API_PORT=.*/API_PORT=5155/' "$ROOT/.env" || true
|
||||
sed -i 's/^ENV_NAME=.*/ENV_NAME=test/' "$ROOT/.env" || true
|
||||
echo "[eth_hedge_sim] wrote .env — please review AUTH_* secrets"
|
||||
fi
|
||||
|
||||
if [[ ! -d "$ROOT/.venv" ]]; then
|
||||
python3 -m venv "$ROOT/.venv"
|
||||
fi
|
||||
# shellcheck disable=SC1091
|
||||
source "$ROOT/.venv/bin/activate"
|
||||
pip install -U pip
|
||||
pip install -r "$ROOT/requirements.txt"
|
||||
|
||||
if ! command -v npm >/dev/null 2>&1; then
|
||||
echo "ERROR: npm not found. Install Node.js 18+ first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$ROOT/frontend"
|
||||
if [[ -f package-lock.json ]]; then npm ci; else npm install; fi
|
||||
npm run build
|
||||
)
|
||||
|
||||
if ! command -v pm2 >/dev/null 2>&1; then
|
||||
npm install -g pm2
|
||||
fi
|
||||
|
||||
# 仅 reload 本项目进程,禁止 pm2 restart all
|
||||
pm2 startOrReload "$ROOT/deploy/ecosystem.config.cjs" --update-env
|
||||
pm2 save
|
||||
|
||||
echo "[eth_hedge_sim] done. health: http://127.0.0.1:5155/health"
|
||||
Reference in New Issue
Block a user