Restructure into modules/ with single-process CTP and config/ layout.
Move business code under modules/, env template to config/, PM2 single qihuo process, and _legacy shims for old imports. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -161,25 +161,27 @@ pip install --upgrade pip -q
|
||||
pip install -r "$APP_DIR/requirements.txt"
|
||||
python -c "from vnpy_ctp import CtpGateway; print('vnpy_ctp OK')"
|
||||
|
||||
echo "==> 配置 .env..."
|
||||
if [ ! -f "$APP_DIR/.env" ]; then
|
||||
cp "$APP_DIR/.env.example" "$APP_DIR/.env"
|
||||
echo "==> 配置 config/.env..."
|
||||
ENV_FILE="$APP_DIR/config/.env"
|
||||
mkdir -p "$APP_DIR/config"
|
||||
if [ ! -f "$ENV_FILE" ]; then
|
||||
cp "$APP_DIR/config/.env.example" "$ENV_FILE"
|
||||
RAND_KEY=$(python3 -c "import secrets; print(secrets.token_hex(32))")
|
||||
sed -i "s/change-this-to-a-random-secret-key/${RAND_KEY}/" "$APP_DIR/.env"
|
||||
echo " 已生成 .env,请编辑 SIMNOW_USER / ADMIN_PASSWORD"
|
||||
sed -i "s/change-this-to-a-random-secret-key/${RAND_KEY}/" "$ENV_FILE"
|
||||
echo " 已生成 config/.env,请编辑 SIMNOW_USER / ADMIN_PASSWORD"
|
||||
fi
|
||||
ensure_env_key "$APP_DIR/.env" "SIMNOW_ENV" "实盘"
|
||||
ensure_env_key "$APP_DIR/.env" "CTP_AUTO_RECONNECT" "true"
|
||||
ensure_env_key "$APP_DIR/.env" "SIMNOW_BROKER_ID" "9999"
|
||||
ensure_env_key "$APP_DIR/.env" "SIMNOW_APP_ID" "simnow_client_test"
|
||||
ensure_env_key "$APP_DIR/.env" "SIMNOW_AUTH_CODE" "0000000000000000"
|
||||
update_simnow_front_in_env "$APP_DIR/.env" || true
|
||||
ensure_env_key "$ENV_FILE" "SIMNOW_ENV" "实盘"
|
||||
ensure_env_key "$ENV_FILE" "CTP_AUTO_RECONNECT" "true"
|
||||
ensure_env_key "$ENV_FILE" "SIMNOW_BROKER_ID" "9999"
|
||||
ensure_env_key "$ENV_FILE" "SIMNOW_APP_ID" "simnow_client_test"
|
||||
ensure_env_key "$ENV_FILE" "SIMNOW_AUTH_CODE" "0000000000000000"
|
||||
update_simnow_front_in_env "$ENV_FILE" || true
|
||||
|
||||
mkdir -p "$APP_DIR/logs"
|
||||
|
||||
echo "==> 验证 CTP 环境..."
|
||||
if grep -q "^SIMNOW_USER=.\+" "$APP_DIR/.env" 2>/dev/null && \
|
||||
grep -q "^SIMNOW_PASSWORD=.\+" "$APP_DIR/.env" 2>/dev/null; then
|
||||
if grep -q "^SIMNOW_USER=.\+" "$ENV_FILE" 2>/dev/null && \
|
||||
grep -q "^SIMNOW_PASSWORD=.\+" "$ENV_FILE" 2>/dev/null; then
|
||||
set +e
|
||||
python "$APP_DIR/scripts/test_simnow.py"
|
||||
CTP_TEST=$?
|
||||
|
||||
Reference in New Issue
Block a user