Merge branch 'hugo-shipping-notice' into dev

This commit is contained in:
hugo committed 2026-09-07 15:09:54 +08:00
commit 7329ccd179
17 files changed
+1195 -184

No files matched your search

+49 -33
View File
@@ -38,6 +38,7 @@ Hxops 与货代系统之间通过 **目录 + JSON 触发文件** 解耦,RPA
| `common/rpa_common.py` | 环境变量、通用 Playwright 点击/填充工具 |
| `common/download_artifact_fallback.py` | 浏览器已落盘但 Playwright 未返回 Download 时的下载适配器 |
| `common/rpa_heartbeat.py` | 向后端上报心跳 + 共享目录哨兵(原 `freight_rpa_heartbeat.py`) |
| `common/worker_disk_cleanup.py` | Worker 本机磁盘保留清理(日志备份 / trigger·drop 归档 / 孤儿 run_* Profile) |
| `common/new_rpa_worker_secret.ps1` | 生成当前用户可解密的 DPAPI Secret 文件 |
| `connectors/` | **登录网站 / 报表系统自动化**(库存与收料共用) |
| `connectors/dsv/` | DSV 360 连接器:`dsv_driver` / `dsv_auth` / `dsv_auth_login_flow` / `dsv_session` / `dsv_navigation` / `dsv_report_export` / `dsv_debug` / `dsv_report_parameters` / `dsv_login_smoke` / `dsv_export_timeout_diagnostics` |
@@ -77,8 +78,13 @@ Hxops 与货代系统之间通过 **目录 + JSON 触发文件** 解耦,RPA
| `SHIPPING_NOTICE_RPA_WORKER_ENVIRONMENT` | `test` / `prod`,须与后端 `ENV_NAME` 一致 |
| `SHIPPING_NOTICE_RPA_WORKER_HEARTBEAT_SECONDS` | 心跳间隔(默认 20s),test/prod 触发前检查依赖在线心跳 |
| `SHIPPING_NOTICE_RPA_CREDENTIAL_KEY` | Profile 凭据 Fernet 主密钥;必须与对应环境后端一致,只能由 Secret 渠道或部署脚本安全注入 |
| `SHIPPING_NOTICE_RPA_WORKER_SESSION_REUSE` | 库存导出是否复用浏览器登录 Profile,默认 `true`;上传任务不受影响 |
| `SHIPPING_NOTICE_RPA_WORKER_SESSION_REUSE_TTL_HOURS` | 持久 Profile 最长保留小时数,默认 `24`;超时后清空目录并重新登录 |
| `SHIPPING_NOTICE_RPA_WORKER_SESSION_REUSE` | 库存导出是否复用浏览器登录 Profile,默认 `true`;上传任务不受影响;站点会话失效时自动重登 |
| `SHIPPING_NOTICE_RPA_WORKER_LOG_FILE` | Worker 文件日志路径(stdout/stderr tee) |
| `SHIPPING_NOTICE_RPA_WORKER_LOG_MAX_BYTES` | 单日志文件大小上限(默认 10MB);启动与周期清理时按大小轮转 |
| `SHIPPING_NOTICE_RPA_WORKER_LOG_BACKUP_COUNT` | 日志备份个数(默认 5) |
| `SHIPPING_NOTICE_RPA_WORKER_DISK_RETENTION_DAYS` | 本机归档保留天数(默认 7);`<=0` 禁用按天清理。覆盖 trigger `processed/failed`、drop 归档/隔离、upload_queue、日志备份 |
| `SHIPPING_NOTICE_RPA_WORKER_DISK_CLEANUP_INTERVAL_SECONDS` | 磁盘清理周期秒数(默认 3600);Worker 启动时会立即清一轮 |
| `SHIPPING_NOTICE_RPA_WORKER_ORPHAN_PROFILE_MAX_AGE_HOURS` | 孤儿临时 `run_*` Profile 最大存活小时(默认 24);`*_session` 会话 Profile 永不删除 |
新部署只使用 `new_rpa_worker_secret.ps1` + `start_rpa_worker.ps1`:Secret 由 DPAPI 保护,环境变量只注入对应 Worker 子进程。
@@ -88,11 +94,16 @@ Hxops 与货代系统之间通过 **目录 + JSON 触发文件** 解耦,RPA
`SHIPPING_NOTICE_RPA_CREDENTIAL_KEY`。部署文档和启动脚本只使用上述规范命名。
DSV/Crane 库存导出默认复用浏览器 Profile(按 `connector + rpa_profile_code` 隔离目录,
默认保留 24 小时)。同一 WorkerRoot 只跑一个 Worker,任务串行消费;会话过期或站点踢登
仍回落现有登录流程。上传任务保持一次性 Profile。若需强制每次全新登录,启动时加
`-NoSessionReuse`。旧参数 `-ReuseDsvSession` / `SHIPPING_NOTICE_RPA_WORKER_DSV_SESSION_REUSE`
长期保留)。同一 WorkerRoot 只跑一个 Worker,任务串行消费;是否免登取决于货代站点会话
是否仍有效,失效时回落现有登录流程。上传任务保持一次性 Profile。若需强制每次全新登录,
启动时加 `-NoSessionReuse`。旧参数 `-ReuseDsvSession` / `SHIPPING_NOTICE_RPA_WORKER_DSV_SESSION_REUSE`
仍兼容,但请改用 `SHIPPING_NOTICE_RPA_WORKER_SESSION_REUSE`。
Worker 默认启用本机磁盘保留清理(`scripts/rpa/common/worker_disk_cleanup.py`):启动与每小时
清理超过保留期的 `processed/failed` trigger、drop 归档(含 `processed` /
`.hxops_quarantine` / `.cleanup_failed`)、过期 drop 根导出文件、upload_queue 残留、
日志备份,以及超过 24h 的孤儿 `run_*` 临时 Profile。**不删除**进行中的 trigger 根 JSON、
可复用会话 Profile、以及活跃的 `.cleanup_queue`。
### DSV WMS Upload Tool
已确认 DSV 上传页为 `WMS Upload Tool > Upload`,页面有 `Browse` 文件选择入口和
@@ -521,20 +532,21 @@ SHIPPING_NOTICE_TOOL_API_KEY
SHIPPING_NOTICE_RPA_CREDENTIAL_KEY
```
如使用 Docker Compose,容器必须挂载对应目录:
如使用 Docker Compose,**写 RPA trigger 的容器都必须挂载**对应目录:`hxops-backend`、`hxops-schedule-worker`(定时导出)、`hxops-shipping-worker`(按需库存准备 Gate Job)。只挂 backend 时,shipping-worker 会在容器本地假目录写 JSON,DB 记 `trigger_written`,但 Windows 共享盘无文件。
```yaml
services:
hxops-backend:
volumes:
- /mnt/hxops-rpa-test-data:/mnt/hxops-rpa-test-data
- /mnt/hxops-rpa-prod-data:/mnt/hxops-rpa-prod-data
# hxops-backend / hxops-schedule-worker / hxops-shipping-worker 均需:
volumes:
- /mnt/hxops-rpa-test-data:/mnt/hxops-rpa-test-data
- /mnt/hxops-rpa-prod-data:/mnt/hxops-rpa-prod-data
```
重建/启动后端容器后验证:
重建相关容器后验证:
```bash
docker compose --env-file .env.test up -d --force-recreate hxops-shipping-worker
docker compose --env-file .env.test exec -T hxops-backend sh -lc 'ls -ld /mnt/hxops-rpa-test-data/inventory_triggers'
docker compose --env-file .env.test exec -T hxops-shipping-worker sh -lc 'mountpoint -q /mnt/hxops-rpa-test-data && ls -ld /mnt/hxops-rpa-test-data/inventory_triggers'
docker compose --env-file .env.prod exec -T hxops-backend sh -lc 'ls -ld /mnt/hxops-rpa-prod-data/inventory_triggers'
```
@@ -861,6 +873,9 @@ $env:SHIPPING_NOTICE_RPA_WORKER_BROWSER_PROFILE_DIR = "C:\HxopsRpaTest\data\brow
$env:SHIPPING_NOTICE_RPA_WORKER_LOG_FILE = "C:\HxopsRpaTest\data\logs\worker.log"
$env:SHIPPING_NOTICE_RPA_WORKER_LOG_MAX_BYTES = "10485760"
$env:SHIPPING_NOTICE_RPA_WORKER_LOG_BACKUP_COUNT = "5"
$env:SHIPPING_NOTICE_RPA_WORKER_DISK_RETENTION_DAYS = "7"
$env:SHIPPING_NOTICE_RPA_WORKER_DISK_CLEANUP_INTERVAL_SECONDS = "3600"
$env:SHIPPING_NOTICE_RPA_WORKER_ORPHAN_PROFILE_MAX_AGE_HOURS = "24"
$env:SHIPPING_NOTICE_RPA_WORKER_DSV_USERNAME = "请替换为DSV账号"
$env:SHIPPING_NOTICE_RPA_WORKER_DSV_PASSWORD = "请替换为DSV密码"
@@ -1022,14 +1037,13 @@ SHIPPING_NOTICE_RPA_WORKER_ALERT_SEND_LOCK_SECONDS=120
sudo systemctl restart hxops-backend
```
如使用 Docker Compose,必须将宿主机挂载目录 bind mount 到容器内相同路径:
如使用 Docker Compose,必须将宿主机挂载目录 bind mount 到**写 trigger 的容器**内相同路径(`hxops-backend`、`hxops-schedule-worker`、`hxops-shipping-worker`):
```yaml
services:
hxops-backend:
volumes:
- /mnt/hxops-rpa-test-data:/mnt/hxops-rpa-test-data
- /mnt/hxops-rpa-prod-data:/mnt/hxops-rpa-prod-data
# hxops-backend / hxops-schedule-worker / hxops-shipping-worker 均需:
volumes:
- /mnt/hxops-rpa-test-data:/mnt/hxops-rpa-test-data
- /mnt/hxops-rpa-prod-data:/mnt/hxops-rpa-prod-data
```
@@ -1188,13 +1202,12 @@ sudo -u hxops touch /mnt/hxops-rpa-test-data/inventory_triggers/linux_write_test
sudo -u hxops rm /mnt/hxops-rpa-test-data/inventory_triggers/linux_write_test.txt
```
`.env.test` 必须指向 `/mnt/hxops-rpa-test-data`,scope 必须为 `hxops-rpa-test-data`。此外,`docker-compose.yml` 的 `hxops-backend` 必须将宿主机挂载目录 bind mount 到容器**同一路径**,否则容器内无法看到 RPA 文件:
`.env.test` 必须指向 `/mnt/hxops-rpa-test-data`,scope 必须为 `hxops-rpa-test-data`。此外,`docker-compose.yml` 的 `hxops-backend`、`hxops-schedule-worker`、`hxops-shipping-worker` 都必须将宿主机挂载目录 bind mount 到容器**同一路径**(按需库存 trigger 由 shipping-worker 写入),否则容器内写到本地假目录、Windows 看不到:
```yaml
services:
hxops-backend:
volumes:
- /mnt/hxops-rpa-test-data:/mnt/hxops-rpa-test-data
# hxops-backend / hxops-schedule-worker / hxops-shipping-worker 均需:
volumes:
- /mnt/hxops-rpa-test-data:/mnt/hxops-rpa-test-data
```
在测试服务器项目根目录启动并验证容器:
@@ -1203,16 +1216,18 @@ services:
export COMPOSE_ENV_BASENAME=.env.test
export COMPOSE_SHARED_ENV_BASENAME=.env.shared
docker compose --env-file .env.test up -d hxops-backend hxops-kb-worker
docker compose --env-file .env.test up -d hxops-backend hxops-kb-worker hxops-shipping-worker hxops-schedule-worker
docker compose --env-file .env.test ps
docker compose --env-file .env.test exec -T hxops-backend \
sh -lc 'test -d /mnt/hxops-rpa-test-data/inventory_triggers && ls -ld /mnt/hxops-rpa-test-data/inventory_triggers'
docker compose --env-file .env.test exec -T hxops-shipping-worker \
sh -lc 'mountpoint -q /mnt/hxops-rpa-test-data && ls -ld /mnt/hxops-rpa-test-data/inventory_triggers'
```
若这是首次把 bind mount 加入 Compose,必须在变更后重新创建后端容器:
若这是首次把 bind mount 加入 Compose,必须在变更后重新创建相关容器:
```bash
docker compose --env-file .env.test up -d --force-recreate hxops-backend
docker compose --env-file .env.test up -d --force-recreate hxops-backend hxops-shipping-worker hxops-schedule-worker
```
@@ -1485,13 +1500,12 @@ cd C:\HxopsRpaProd
#### 2. 启动正式 Linux 后端并验证共享
在正式服务器项目根目录执行。前提是 `/mnt/hxops-rpa-prod-data` 已经通过受控 SMB 凭据挂载,且 `docker-compose.yml` 已有如下 bind mount:
在正式服务器项目根目录执行。前提是 `/mnt/hxops-rpa-prod-data` 已经通过受控 SMB 凭据挂载,且 `docker-compose.yml` 中 `hxops-backend` / `hxops-schedule-worker` / `hxops-shipping-worker` 均已 bind mount:
```yaml
services:
hxops-backend:
volumes:
- /mnt/hxops-rpa-prod-data:/mnt/hxops-rpa-prod-data
# 三个服务均需:
volumes:
- /mnt/hxops-rpa-prod-data:/mnt/hxops-rpa-prod-data
```
```bash
@@ -1501,10 +1515,12 @@ test -d /mnt/hxops-rpa-prod-data/inventory_triggers
export COMPOSE_ENV_BASENAME=.env.prod
export COMPOSE_SHARED_ENV_BASENAME=.env.shared
docker compose --env-file .env.prod up -d hxops-backend hxops-kb-worker
docker compose --env-file .env.prod up -d hxops-backend hxops-kb-worker hxops-shipping-worker hxops-schedule-worker
docker compose --env-file .env.prod ps
docker compose --env-file .env.prod exec -T hxops-backend \
sh -lc 'test -d /mnt/hxops-rpa-prod-data/inventory_triggers && ls -ld /mnt/hxops-rpa-prod-data/inventory_triggers'
docker compose --env-file .env.prod exec -T hxops-shipping-worker \
sh -lc 'mountpoint -q /mnt/hxops-rpa-prod-data && ls -ld /mnt/hxops-rpa-prod-data/inventory_triggers'
cat /mnt/hxops-rpa-prod-data/inventory_triggers/.hxops_rpa_shared_mount
```
@@ -1595,7 +1611,7 @@ $env:SHIPPING_NOTICE_RPA_WORKER_CRANE_PASSWORD = "<Crane密码>"
python scripts/rpa/inventory/inventory_rpa_worker.py
```
说明:`SHIPPING_NOTICE_RPA_WORKER_BROWSER_PROFILE_DIR` 是浏览器 Profile 根目录。库存导出默认开启会话复用:目录形如 `{connector}__{rpa_profile_code}_session`,跨任务保留登录态,默认 TTL 24 小时(`SHIPPING_NOTICE_RPA_WORKER_SESSION_REUSE_TTL_HOURS`);关闭复用或上传任务仍使用 `run_*` 一次性子目录并在结束后清理。同一 WorkerRoot 不要并发启动第二个库存 Worker。
说明:`SHIPPING_NOTICE_RPA_WORKER_BROWSER_PROFILE_DIR` 是浏览器 Profile 根目录。库存导出默认开启会话复用:目录形如 `{connector}__{rpa_profile_code}_session`,跨任务长期保留登录态,不以本地 TTL 强制清空;站点会话失效时由登录流程重登。关闭复用或上传任务仍使用 `run_*` 一次性子目录并在结束后清理。同一 WorkerRoot 不要并发启动第二个库存 Worker。
如果登录框默认识别不稳定,可覆盖登录 selector:
+426
View File
@@ -0,0 +1,426 @@
"""
scripts/rpa/common/worker_disk_cleanup.py
用途:RPA Worker 本机磁盘保留清理,防止 logs / 归档 trigger / drop 归档 / 孤儿临时 Profile 长期堆积撑爆盘符。
依赖:rpa_common.env、pathlib、shutil、time。
逻辑:由 inventory(及可复用的 receipt)Worker 主循环周期调用;只删超过保留期的归档与临时物,
绝不删除进行中的 trigger 根目录 JSON、可复用会话 Profile(*_session)、以及活跃 cleanup 队列。
"""
from __future__ import annotations
import sys as _sys
from pathlib import Path as _Path
_RPA_ROOT = next(
(
_c
for _c in _Path(__file__).resolve().parents
if (_c / "connectors").is_dir()
and (_c / "common").is_dir()
and (_c / "inventory").is_dir()
and (_c / "receipt").is_dir()
),
None,
)
if _RPA_ROOT is not None:
for _rel in ("", "common", "connectors", "connectors/dsv", "connectors/crane", "inventory", "receipt"):
_dir = str(_RPA_ROOT) if not _rel else str(_RPA_ROOT / _rel)
if _dir not in _sys.path:
_sys.path.insert(0, _dir)
import shutil
import time
from datetime import UTC, datetime
from pathlib import Path
from typing import Callable
from rpa_common import env as _env
_PROTECTED_DROP_DIRNAMES = frozenset(
{
"processed",
".hxops_quarantine",
".cleanup_queue",
".cleanup_failed",
".hxops_rpa_shared_mount",
}
)
_DROP_ROOT_SUFFIXES = frozenset({".xlsx", ".xls", ".csv", ".hxops_consumed"})
_TRIGGER_ARCHIVE_DIRNAMES = ("processed", "failed")
_DEFAULT_RETENTION_DAYS = 7
_DEFAULT_INTERVAL_SECONDS = 3600
_DEFAULT_ORPHAN_PROFILE_HOURS = 24
class DiskCleanupStats:
"""单次清理统计,便于日志汇总与单测断言。"""
def __init__(self) -> None:
self.deleted_files = 0
self.deleted_dirs = 0
self.skipped = 0
self.errors = 0
self.details: list[str] = []
def record_file(self, path: Path) -> None:
self.deleted_files += 1
self.details.append(f"file:{path}")
def record_dir(self, path: Path) -> None:
self.deleted_dirs += 1
self.details.append(f"dir:{path}")
def record_error(self, path: Path, exc: BaseException) -> None:
self.errors += 1
self.details.append(f"error:{path}:{type(exc).__name__}")
def retention_days() -> int:
"""
读取归档保留天数。
核心逻辑:`SHIPPING_NOTICE_RPA_WORKER_DISK_RETENTION_DAYS`,默认 7;
`<=0` 表示禁用按天清理(仍可单独清理孤儿临时 Profile,见 orphan 配置)。
Returns:
int: 保留天数;禁用时为 0。
"""
return _int_env("SHIPPING_NOTICE_RPA_WORKER_DISK_RETENTION_DAYS", _DEFAULT_RETENTION_DAYS, min_value=0)
def cleanup_interval_seconds() -> int:
"""
读取清理周期秒数。
核心逻辑:`SHIPPING_NOTICE_RPA_WORKER_DISK_CLEANUP_INTERVAL_SECONDS`,默认 3600;
最小值 60,避免主循环过于频繁扫盘。
Returns:
int: 清理间隔秒数。
"""
return _int_env(
"SHIPPING_NOTICE_RPA_WORKER_DISK_CLEANUP_INTERVAL_SECONDS",
_DEFAULT_INTERVAL_SECONDS,
min_value=60,
)
def orphan_profile_max_age_seconds() -> int:
"""
读取孤儿临时 Profile(run_*)最大存活秒数。
核心逻辑:`SHIPPING_NOTICE_RPA_WORKER_ORPHAN_PROFILE_MAX_AGE_HOURS`,默认 24;
`<=0` 禁用孤儿 Profile 清理。会话复用目录(*_session)永不删除。
Returns:
int: 最大存活秒数;禁用时为 0。
"""
hours = _int_env(
"SHIPPING_NOTICE_RPA_WORKER_ORPHAN_PROFILE_MAX_AGE_HOURS",
_DEFAULT_ORPHAN_PROFILE_HOURS,
min_value=0,
)
return hours * 3600
def _int_env(name: str, default: int, *, min_value: int = 0) -> int:
"""读取整数环境变量;非法值回退默认,并钳制下限。"""
try:
value = int(_env(name, str(default)) or str(default))
except ValueError:
return default
return max(value, min_value)
def _mtime_unix(path: Path) -> float | None:
"""读取 mtime;失败返回 None。"""
try:
return path.stat().st_mtime
except OSError:
return None
def _is_older_than(path: Path, *, cutoff_unix: float) -> bool:
"""路径 mtime 早于 cutoff 时视为过期。"""
mtime = _mtime_unix(path)
if mtime is None:
return False
return mtime < cutoff_unix
def _safe_unlink(path: Path, stats: DiskCleanupStats) -> None:
"""best-effort 删除文件。"""
try:
if path.is_file() or path.is_symlink():
path.unlink(missing_ok=True)
stats.record_file(path)
else:
stats.skipped += 1
except OSError as exc:
stats.record_error(path, exc)
def _safe_rmtree(path: Path, stats: DiskCleanupStats) -> None:
"""best-effort 删除目录树。"""
try:
if path.is_dir():
shutil.rmtree(path, ignore_errors=False)
stats.record_dir(path)
else:
stats.skipped += 1
except OSError as exc:
stats.record_error(path, exc)
def cleanup_files_older_than(
directory: Path,
*,
cutoff_unix: float,
stats: DiskCleanupStats,
recursive: bool = False,
name_predicate: Callable[[Path], bool] | None = None,
suffix_allowlist: frozenset[str] | None = None,
) -> None:
"""
删除目录中超过 cutoff 的文件(可选递归、文件名/后缀过滤)。
核心逻辑:只处理普通文件;目录本身不删(由调用方决定是否 rmtree)。
匹配失败或权限错误计入 stats,不中断整轮清理。
Args:
directory: 目标目录;不存在则跳过。
cutoff_unix: 早于此 Unix 时间戳的文件可删。
stats: 累计统计。
recursive: 是否递归子目录。
name_predicate: 可选文件名过滤;返回 False 则跳过。
suffix_allowlist: 可选后缀白名单(小写,含点);None 表示不限制。
"""
if not directory.is_dir():
return
iterator = directory.rglob("*") if recursive else directory.iterdir()
for path in iterator:
try:
if not path.is_file():
continue
except OSError as exc:
stats.record_error(path, exc)
continue
if name_predicate is not None and not name_predicate(path):
stats.skipped += 1
continue
if suffix_allowlist is not None and path.suffix.lower() not in suffix_allowlist:
# 兼容 sidecar:`.xlsx.hxops_consumed` 的 suffix 是 `.hxops_consumed`
if path.name.endswith(".hxops_consumed") and ".hxops_consumed" in suffix_allowlist:
pass
else:
stats.skipped += 1
continue
if not _is_older_than(path, cutoff_unix=cutoff_unix):
stats.skipped += 1
continue
_safe_unlink(path, stats)
def cleanup_trigger_archives(trigger_dir: Path | None, *, cutoff_unix: float, stats: DiskCleanupStats) -> None:
"""
清理 trigger 下 processed/failed 归档 JSON。
核心逻辑:绝不触碰 trigger 根目录进行中的 `*.json`。
"""
if trigger_dir is None or not trigger_dir.is_dir():
return
for dirname in _TRIGGER_ARCHIVE_DIRNAMES:
cleanup_files_older_than(
trigger_dir / dirname,
cutoff_unix=cutoff_unix,
stats=stats,
recursive=False,
suffix_allowlist=frozenset({".json"}),
)
def cleanup_drop_archives(drop_dir: Path | None, *, cutoff_unix: float, stats: DiskCleanupStats) -> None:
"""
清理 drop 区归档与隔离目录,以及根目录过期导出文件。
核心逻辑:
- 清理 `processed` / `.hxops_quarantine` / `.cleanup_failed` 中过期文件;
- 清理 drop 根目录过期的 Excel/CSV 与 `.hxops_consumed` sidecar;
- 不碰 `.cleanup_queue`(活跃重试队列)。
"""
if drop_dir is None or not drop_dir.is_dir():
return
for dirname in ("processed", ".hxops_quarantine", ".cleanup_failed"):
cleanup_files_older_than(
drop_dir / dirname,
cutoff_unix=cutoff_unix,
stats=stats,
recursive=False,
)
# [STEP 1] drop 根:仅清理导出产物与消费标记,跳过受保护子目录与其它文件
for path in drop_dir.iterdir():
try:
if path.is_dir():
if path.name in _PROTECTED_DROP_DIRNAMES or path.name.startswith("."):
stats.skipped += 1
continue
if not path.is_file():
continue
except OSError as exc:
stats.record_error(path, exc)
continue
suffix = path.suffix.lower()
is_consumed_sidecar = path.name.endswith(".hxops_consumed")
if suffix not in _DROP_ROOT_SUFFIXES and not is_consumed_sidecar:
stats.skipped += 1
continue
if not _is_older_than(path, cutoff_unix=cutoff_unix):
stats.skipped += 1
continue
_safe_unlink(path, stats)
def cleanup_upload_queue(queue_dir: Path | None, *, cutoff_unix: float, stats: DiskCleanupStats) -> None:
"""
清理 upload_queue 中过期文件。
核心逻辑:待上传文件正常应在数分钟内被消费;超过保留期视为残留,可删。
"""
if queue_dir is None or not queue_dir.is_dir():
return
cleanup_files_older_than(queue_dir, cutoff_unix=cutoff_unix, stats=stats, recursive=False)
def cleanup_log_backups(log_file: Path | None, *, cutoff_unix: float, stats: DiskCleanupStats) -> None:
"""
清理 worker 日志轮转备份(worker.log.1 / .2 ...)。
核心逻辑:不删当前 `worker.log`(由大小轮转负责);只删过期备份。
"""
if log_file is None:
return
parent = log_file.parent
if not parent.is_dir():
return
prefix = f"{log_file.name}."
for path in parent.iterdir():
try:
if not path.is_file():
continue
except OSError as exc:
stats.record_error(path, exc)
continue
if path.name == log_file.name:
stats.skipped += 1
continue
if not path.name.startswith(prefix):
continue
suffix = path.name[len(prefix) :]
if not suffix.isdigit():
continue
if not _is_older_than(path, cutoff_unix=cutoff_unix):
stats.skipped += 1
continue
_safe_unlink(path, stats)
def cleanup_orphan_runtime_profiles(
profile_root: Path | None,
*,
cutoff_unix: float,
stats: DiskCleanupStats,
) -> None:
"""
清理浏览器 Profile 根下过期的一次性 `run_*` 目录。
核心逻辑:会话复用目录名以 `_session` 结尾或历史 `dsv360_session`,一律保留;
仅删除 `run_*` 临时目录,避免异常中断后残留撑盘。
"""
if profile_root is None or not profile_root.is_dir():
return
for path in profile_root.iterdir():
try:
if not path.is_dir():
continue
except OSError as exc:
stats.record_error(path, exc)
continue
name = path.name
if name.endswith("_session") or name == "dsv360_session":
stats.skipped += 1
continue
if not name.startswith("run_"):
stats.skipped += 1
continue
if not _is_older_than(path, cutoff_unix=cutoff_unix):
stats.skipped += 1
continue
_safe_rmtree(path, stats)
def run_worker_disk_cleanup(
*,
inventory_trigger_dir: Path | None = None,
upload_trigger_dir: Path | None = None,
drop_dir: Path | None = None,
upload_queue_dir: Path | None = None,
browser_profile_dir: Path | None = None,
log_file: Path | None = None,
now_unix: float | None = None,
) -> DiskCleanupStats:
"""
执行一轮 Worker 本机磁盘保留清理。
【AI 触发时机】:Worker 启动后及主循环按 `DISK_CLEANUP_INTERVAL_SECONDS` 周期调用。
核心逻辑:按 `DISK_RETENTION_DAYS` 清理归档/日志备份/队列残留;按
`ORPHAN_PROFILE_MAX_AGE_HOURS` 清理孤儿 `run_*` Profile。全部 best-effort。
Args:
inventory_trigger_dir: 库存 trigger 根目录。
upload_trigger_dir: 上传 trigger 根目录。
drop_dir: 库存 drop 根目录。
upload_queue_dir: 上传队列目录。
browser_profile_dir: 浏览器 Profile 根目录。
log_file: 当前 worker 日志文件路径。
now_unix: 可选当前时间(单测注入)。
Returns:
DiskCleanupStats: 本轮删除/跳过/错误统计。
"""
stats = DiskCleanupStats()
now = float(now_unix if now_unix is not None else time.time())
days = retention_days()
if days > 0:
cutoff = now - (days * 86400)
cleanup_trigger_archives(inventory_trigger_dir, cutoff_unix=cutoff, stats=stats)
cleanup_trigger_archives(upload_trigger_dir, cutoff_unix=cutoff, stats=stats)
cleanup_drop_archives(drop_dir, cutoff_unix=cutoff, stats=stats)
cleanup_upload_queue(upload_queue_dir, cutoff_unix=cutoff, stats=stats)
cleanup_log_backups(log_file, cutoff_unix=cutoff, stats=stats)
orphan_age = orphan_profile_max_age_seconds()
if orphan_age > 0:
cleanup_orphan_runtime_profiles(
browser_profile_dir,
cutoff_unix=now - orphan_age,
stats=stats,
)
return stats
def format_cleanup_summary(stats: DiskCleanupStats) -> str:
"""
将清理统计格式化为单行日志。
Args:
stats: 清理结果。
Returns:
str: 适合 print 的摘要。
"""
stamp = datetime.now(UTC).astimezone().strftime("%Y-%m-%d %H:%M:%S")
return (
f"[disk-cleanup] at={stamp} deleted_files={stats.deleted_files} "
f"deleted_dirs={stats.deleted_dirs} skipped={stats.skipped} errors={stats.errors}"
)
+176 -62
View File
@@ -20,7 +20,6 @@ Optional:
SHIPPING_NOTICE_RPA_WORKER_SAMPLE_INVENTORY=path/to/sample.xlsx
SHIPPING_NOTICE_RPA_WORKER_BROWSER_PROFILE_DIR=data/shipping_notice/freight_rpa/browser_profile
SHIPPING_NOTICE_RPA_WORKER_SESSION_REUSE=true
SHIPPING_NOTICE_RPA_WORKER_SESSION_REUSE_TTL_HOURS=24
# legacy alias: SHIPPING_NOTICE_RPA_WORKER_DSV_SESSION_REUSE
SHIPPING_NOTICE_RPA_WORKER_HEADLESS=false
SHIPPING_NOTICE_RPA_WORKER_BROWSER_CHANNEL=msedge
@@ -28,6 +27,9 @@ Optional:
SHIPPING_NOTICE_RPA_WORKER_LOG_FILE=C:\\HxopsRpaTest\\data\\logs\\worker.log
SHIPPING_NOTICE_RPA_WORKER_LOG_MAX_BYTES=10485760
SHIPPING_NOTICE_RPA_WORKER_LOG_BACKUP_COUNT=5
SHIPPING_NOTICE_RPA_WORKER_DISK_RETENTION_DAYS=7
SHIPPING_NOTICE_RPA_WORKER_DISK_CLEANUP_INTERVAL_SECONDS=3600
SHIPPING_NOTICE_RPA_WORKER_ORPHAN_PROFILE_MAX_AGE_HOURS=24
SHIPPING_NOTICE_RPA_WORKER_DSV_USERNAME / SHIPPING_NOTICE_RPA_WORKER_DSV_PASSWORD
SHIPPING_NOTICE_RPA_WORKER_CRANE_USERNAME / SHIPPING_NOTICE_RPA_WORKER_CRANE_PASSWORD
SHIPPING_NOTICE_RPA_WORKER_UPLOAD_ENABLED=false
@@ -83,6 +85,7 @@ import dsv_report_export # noqa: E402
from dsv_report_export import NoInventoryDataError # noqa: E402
import dsv_session # noqa: E402
import rpa_heartbeat # noqa: E402
import worker_disk_cleanup # noqa: E402
# 测试与 smoke 向后兼容 re-export
_maybe_auto_login_dsv = dsv_session.maybe_auto_login_dsv
@@ -144,7 +147,7 @@ class _TeeStream:
核心逻辑:保留原 stdout/stderr,避免计划任务改为日志模式后本地调试看不到输出;
每行完整输出前自动前缀本地时间戳;文件 flush 采用行级同步,RPA 异常退出时尽量
保留最后几行排障信息。
保留最后几行排障信息;支持运行中替换底层日志句柄以便按大小轮转。
"""
def __init__(self, console: TextIO, log_file: TextIO) -> None:
@@ -153,6 +156,23 @@ class _TeeStream:
self._pending = ""
self.encoding = getattr(console, "encoding", "utf-8")
def replace_log_file(self, log_file: TextIO) -> TextIO:
"""
替换底层日志文件句柄(用于运行中轮转)。
核心逻辑:先 flush 缓冲,再切换句柄;调用方负责关闭旧句柄与打开新文件。
Args:
log_file: 新的追加写日志句柄。
Returns:
TextIO: 被替换下来的旧日志句柄。
"""
self.flush()
previous = self._log_file
self._log_file = log_file
return previous
def _emit_line(self, line: str, *, newline: bool) -> None:
"""将单行(可含时间戳前缀)写入控制台与日志文件。"""
if line:
@@ -182,6 +202,13 @@ class _TeeStream:
return bool(getattr(self._console, "isatty", lambda: False)())
# 运行中日志轮转需要持有 Tee 与路径;仅由 _configure_file_logging / _maybe_rotate_open_log 维护。
_ACTIVE_LOG_PATH: Path | None = None
_ACTIVE_STDOUT_TEE: _TeeStream | None = None
_ACTIVE_STDERR_TEE: _TeeStream | None = None
_ACTIVE_LOG_HANDLE: TextIO | None = None
def _configure_file_logging() -> Path | None:
"""
按 SHIPPING_NOTICE_RPA_WORKER_LOG_FILE 启用 worker 文件日志。
@@ -193,6 +220,7 @@ def _configure_file_logging() -> Path | None:
Returns:
Path | None: 已启用的日志路径;未配置时返回 None。
"""
global _ACTIVE_LOG_PATH, _ACTIVE_STDOUT_TEE, _ACTIVE_STDERR_TEE, _ACTIVE_LOG_HANDLE
raw = _env("SHIPPING_NOTICE_RPA_WORKER_LOG_FILE")
if not raw:
return None
@@ -204,19 +232,71 @@ def _configure_file_logging() -> Path | None:
log_file = path.open("a", encoding="utf-8", buffering=1)
original_stdout = sys.stdout
original_stderr = sys.stderr
sys.stdout = _TeeStream(original_stdout, log_file) # type: ignore[assignment]
sys.stderr = _TeeStream(original_stderr, log_file) # type: ignore[assignment]
stdout_tee = _TeeStream(original_stdout, log_file)
stderr_tee = _TeeStream(original_stderr, log_file)
sys.stdout = stdout_tee # type: ignore[assignment]
sys.stderr = stderr_tee # type: ignore[assignment]
_ACTIVE_LOG_PATH = path
_ACTIVE_STDOUT_TEE = stdout_tee
_ACTIVE_STDERR_TEE = stderr_tee
_ACTIVE_LOG_HANDLE = log_file
def _close_log() -> None:
global _ACTIVE_LOG_PATH, _ACTIVE_STDOUT_TEE, _ACTIVE_STDERR_TEE, _ACTIVE_LOG_HANDLE
sys.stdout = original_stdout
sys.stderr = original_stderr
log_file.close()
handle = _ACTIVE_LOG_HANDLE or log_file
try:
handle.close()
except Exception:
pass
_ACTIVE_LOG_PATH = None
_ACTIVE_STDOUT_TEE = None
_ACTIVE_STDERR_TEE = None
_ACTIVE_LOG_HANDLE = None
atexit.register(_close_log)
print(f"[logging] tee enabled path={path}")
return path
def _maybe_rotate_open_log() -> None:
"""
常驻 Worker 运行中按大小轮转当前日志。
核心逻辑:Windows 下无法对仍打开的文件 rename,须先关闭句柄 → 调用既有
`_rotate_log_file_if_needed` → 再以追加模式打开新文件并挂回 TeeStream。
未启用文件日志或未超限时 no-op。
"""
global _ACTIVE_LOG_HANDLE
path = _ACTIVE_LOG_PATH
stdout_tee = _ACTIVE_STDOUT_TEE
stderr_tee = _ACTIVE_STDERR_TEE
handle = _ACTIVE_LOG_HANDLE
if path is None or stdout_tee is None or stderr_tee is None or handle is None:
return
max_bytes = _log_int_env("SHIPPING_NOTICE_RPA_WORKER_LOG_MAX_BYTES", 10 * 1024 * 1024, min_value=0)
if max_bytes <= 0:
return
try:
handle.flush()
if path.stat().st_size < max_bytes:
return
except OSError:
return
try:
handle.close()
except Exception:
pass
_ACTIVE_LOG_HANDLE = None
_rotate_log_file_if_needed(path)
new_handle = path.open("a", encoding="utf-8", buffering=1)
stdout_tee.replace_log_file(new_handle)
stderr_tee.replace_log_file(new_handle)
_ACTIVE_LOG_HANDLE = new_handle
print(f"[logging] rotated open log path={path}")
def _log_int_env(name: str, default: int, *, min_value: int = 0) -> int:
"""读取日志相关整数环境变量;非法值回退默认值。"""
try:
@@ -879,21 +959,6 @@ def _dsv_session_reuse_enabled() -> bool:
return _session_reuse_enabled()
def _session_reuse_ttl_seconds() -> int:
"""
返回持久 Profile 最长保留秒数。
核心逻辑:读取 `SHIPPING_NOTICE_RPA_WORKER_SESSION_REUSE_TTL_HOURS`,默认 24 小时;
下限 1 小时,避免误配成 0 导致每次都重建。
"""
raw = _env("SHIPPING_NOTICE_RPA_WORKER_SESSION_REUSE_TTL_HOURS", "24") or "24"
try:
hours = int(raw)
except ValueError:
hours = 24
return max(1, hours) * 3600
def _sanitize_profile_dir_segment(value: str) -> str:
"""
将 connector / RPA Profile 编码成可作目录名的安全片段。
@@ -915,7 +980,7 @@ def _session_profile_dir(connector_type: str, profile_code: str = "") -> Path:
核心逻辑:目录形如 `{connector}__{profile_code}_session`,不同货代账号绝不共用;
若仍存在历史 `dsv360_session` 且目标目录尚未创建、profile 为 default,则沿用旧目录
以保留已有登录态,待 TTL 过期后自然重建到新命名。
以保留已有登录态。本地不按时间强制清空;站点会话失效时由登录流程兜底重登。
Args:
connector_type: Worker 连接器名(如 dsv360 / crane_footprint)。
@@ -972,7 +1037,6 @@ def _write_session_meta(
"last_used_at": datetime.fromtimestamp(now, tz=UTC).isoformat(),
"connector_type": connector_type,
"profile_code": profile_code,
"ttl_hours": max(1, _session_reuse_ttl_seconds() // 3600),
}
meta_path = profile_dir / _SESSION_META_FILENAME
meta_path.write_text(json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8")
@@ -985,10 +1049,10 @@ def _prepare_reusable_session_profile(
profile_code: str,
) -> Path:
"""
准备可复用 Profile 目录:超 TTL 则清空重建,否则刷新 last_used。
准备可复用 Profile 目录:确保存在并刷新 last_used,不按本地时间强制过期。
核心逻辑:以 meta 的 `created_at_unix` 起算;无 meta 时用目录 mtime。超过
`SESSION_REUSE_TTL_HOURS`(默认 24h)则整目录删除后重建,迫使重新登录。
核心逻辑:目录长期保留 Cookie/登录态;是否免登由货代站点会话是否仍有效决定,
失效时各 connector 的 ensure_session / 登录流程会自动重登。
Args:
profile_dir: 目标持久目录。
@@ -996,47 +1060,21 @@ def _prepare_reusable_session_profile(
profile_code: RPA Profile 编码,写入 meta。
Returns:
Path: 已确保存在且未过期的 profile 目录。
Path: 已确保存在的 profile 目录。
"""
ttl_seconds = _session_reuse_ttl_seconds()
now = time.time()
if profile_dir.exists():
meta = _read_session_meta(profile_dir)
created_at = meta.get("created_at_unix")
try:
created_ts = float(created_at) if created_at is not None else profile_dir.stat().st_mtime
except (TypeError, ValueError, OSError):
created_ts = now
age_seconds = max(0.0, now - created_ts)
if age_seconds >= ttl_seconds:
print(
"[browser] session_reuse expired "
f"ageHours={age_seconds / 3600:.1f} ttlHours={ttl_seconds / 3600:.0f} "
f"dir={profile_dir.name!r}; recreating"
)
shutil.rmtree(profile_dir, ignore_errors=True)
profile_dir.mkdir(parents=True, exist_ok=True)
_write_session_meta(
profile_dir,
connector_type=connector_type,
profile_code=profile_code,
created_at_unix=now,
)
return profile_dir
profile_dir.mkdir(parents=True, exist_ok=True)
_write_session_meta(
profile_dir,
connector_type=connector_type,
profile_code=profile_code,
created_at_unix=created_ts,
)
return profile_dir
profile_dir.mkdir(parents=True, exist_ok=True)
meta = _read_session_meta(profile_dir)
created_at = meta.get("created_at_unix")
try:
created_ts = float(created_at) if created_at is not None else now
except (TypeError, ValueError):
created_ts = now
_write_session_meta(
profile_dir,
connector_type=connector_type,
profile_code=profile_code,
created_at_unix=now,
created_at_unix=created_ts,
)
return profile_dir
@@ -1086,8 +1124,8 @@ def _open_browser(
打开用于库存 / 上传 RPA 的浏览器上下文。
核心逻辑:库存导出在 `reuse_session=True` 且 `SESSION_REUSE` 开启时,使用
`{connector}__{profile_code}_session` 持久目录并按 TTL 失效重建;关闭复用或上传
任务则创建 `run_*` 一次性目录。会话失效仍由各 connector 登录流程兜底。
`{connector}__{profile_code}_session` 持久目录长期保留登录态;关闭复用或上传
任务则创建 `run_*` 一次性目录。站点会话失效时由各 connector 登录流程兜底。
Args:
download_dir: 当前任务下载目录,浏览器 downloads_path 指向此处。
@@ -2479,8 +2517,60 @@ def _scan_triggers(trigger_dir: Path, handler, extra_args: tuple = ()) -> None:
rpa_heartbeat.set_worker_runtime_status("idle")
def _run_periodic_disk_cleanup(
*,
inv_trigger_dir: Path,
upload_trigger_dir: Path,
drop_dir: Path,
upload_queue_dir: Path,
force: bool = False,
last_cleanup_mono: float = 0.0,
) -> float:
"""
按间隔执行本机磁盘保留清理,并尝试运行中日志轮转。
核心逻辑:默认每 `DISK_CLEANUP_INTERVAL_SECONDS` 跑一轮;清理归档 trigger/drop、
日志备份、upload_queue 残留与孤儿 `run_*` Profile;同时按大小轮转打开中的 worker.log。
Args:
inv_trigger_dir: 库存 trigger 根目录。
upload_trigger_dir: 上传 trigger 根目录。
drop_dir: 库存 drop 根目录。
upload_queue_dir: 上传队列目录。
force: True 时忽略间隔立即执行(启动时)。
last_cleanup_mono: 上次清理的 monotonic 时间戳。
Returns:
float: 更新后的 last_cleanup_mono(未执行则原样返回)。
"""
interval = worker_disk_cleanup.cleanup_interval_seconds()
now_mono = time.monotonic()
if not force and (now_mono - last_cleanup_mono) < interval:
return last_cleanup_mono
try:
_maybe_rotate_open_log()
stats = worker_disk_cleanup.run_worker_disk_cleanup(
inventory_trigger_dir=inv_trigger_dir,
upload_trigger_dir=upload_trigger_dir,
drop_dir=drop_dir,
upload_queue_dir=upload_queue_dir,
browser_profile_dir=_browser_profile_root(),
log_file=_ACTIVE_LOG_PATH,
)
print(worker_disk_cleanup.format_cleanup_summary(stats))
except Exception as exc:
print(f"[disk-cleanup] failed: {exc}", file=sys.stderr)
return now_mono
def main() -> None:
_configure_file_logging()
"""
库存 RPA Worker 入口:启日志、心跳、周期磁盘清理,并串行消费 trigger。
核心逻辑:主循环扫描库存/上传 trigger;空闲时按间隔清理本机归档与临时文件,
防止长期运行撑爆 RPA 主机盘符。
"""
log_path = _configure_file_logging()
drop_dir = _require_path("SHIPPING_NOTICE_RPA_SHARED_INVENTORY_DROP_DIR")
inv_trigger_dir = _require_path("SHIPPING_NOTICE_RPA_SHARED_INVENTORY_TRIGGER_DIR")
upload_queue_dir = _require_path("SHIPPING_NOTICE_RPA_SHARED_UPLOAD_QUEUE_DIR")
@@ -2506,6 +2596,14 @@ def main() -> None:
print(f" upload_triggers={upload_trigger_dir}")
print(f" drop={drop_dir}")
print(f" queue={upload_queue_dir}")
print(f" log={log_path or 'disabled'}")
print(
" disk_retention_days="
f"{worker_disk_cleanup.retention_days()} "
f"cleanup_interval_seconds={worker_disk_cleanup.cleanup_interval_seconds()} "
f"orphan_profile_max_age_hours="
f"{max(0, worker_disk_cleanup.orphan_profile_max_age_seconds() // 3600)}"
)
# 启动时立即上报一次,让管理端第一时间看到 Worker 上线。
rpa_heartbeat.maybe_send_heartbeat(
@@ -2522,9 +2620,25 @@ def main() -> None:
interval_seconds=heartbeat_seconds,
)
# [STEP 1] 启动即清一轮,避免重启前长期堆积的归档立刻撑盘
last_cleanup_mono = _run_periodic_disk_cleanup(
inv_trigger_dir=inv_trigger_dir,
upload_trigger_dir=upload_trigger_dir,
drop_dir=drop_dir,
upload_queue_dir=upload_queue_dir,
force=True,
)
while True:
_scan_triggers(inv_trigger_dir, _handle_inventory_trigger, (drop_dir, inv_processed))
_scan_triggers(upload_trigger_dir, _handle_upload_trigger, (upload_processed,))
last_cleanup_mono = _run_periodic_disk_cleanup(
inv_trigger_dir=inv_trigger_dir,
upload_trigger_dir=upload_trigger_dir,
drop_dir=drop_dir,
upload_queue_dir=upload_queue_dir,
last_cleanup_mono=last_cleanup_mono,
)
time.sleep(poll)
@@ -8,7 +8,9 @@
每个环境必须有独立 root、scope、共享目录、browser profile、日志和 DPAPI Secret 文件。
DSV/Crane 登录地址、账号和密码来自 HXOPS trigger 的 credential_envelope,
不从本机 Secret 文件读取。
默认开启库存会话复用(SESSION_REUSE + 24h TTL);需要每次全新登录时传 -NoSessionReuse。
默认开启库存会话复用(SESSION_REUSE,长期保留 Profile;站点会话失效才重登);
需要每次全新登录时传 -NoSessionReuse。
默认启用本机磁盘保留清理(7 天归档 / 每小时一轮 / 24h 孤儿 run_* Profile)。
#>
param(
[Parameter(Mandatory = $true)]
@@ -65,7 +67,7 @@ foreach ($required in @("ToolApiKey", "CredentialKey")) {
}
}
# 库存 Profile 默认按 connector+rpa_profile 复用,TTL 24h;-NoSessionReuse 可关闭。
# 库存 Profile 默认按 connector+rpa_profile 长期复用;-NoSessionReuse 可关闭。
$sessionReuse = if ($NoSessionReuse) { "false" } else { "true" }
if ($ReuseSession -or $ReuseDsvSession) {
$sessionReuse = "true"
@@ -82,7 +84,6 @@ $processVars = [ordered]@{
SHIPPING_NOTICE_RPA_WORKER_MOCK = $(if ($Mock) { "true" } else { "false" })
SHIPPING_NOTICE_RPA_WORKER_HEADLESS = $(if ($Headless) { "true" } else { "false" })
SHIPPING_NOTICE_RPA_WORKER_SESSION_REUSE = $sessionReuse
SHIPPING_NOTICE_RPA_WORKER_SESSION_REUSE_TTL_HOURS = "24"
SHIPPING_NOTICE_RPA_WORKER_BROWSER_CHANNEL = "msedge"
SHIPPING_NOTICE_RPA_WORKER_POLL_SECONDS = "3"
SHIPPING_NOTICE_RPA_SHARED_INVENTORY_TRIGGER_DIR = Join-Path $dataRoot "inventory_triggers"
@@ -93,6 +94,10 @@ $processVars = [ordered]@{
SHIPPING_NOTICE_RPA_WORKER_LOG_FILE = Join-Path $dataRoot "logs\worker.log"
SHIPPING_NOTICE_RPA_WORKER_LOG_MAX_BYTES = "10485760"
SHIPPING_NOTICE_RPA_WORKER_LOG_BACKUP_COUNT = "5"
# 本机磁盘保留:归档 trigger/drop、日志备份、upload_queue、孤儿 run_* Profile;会话 Profile 不删。
SHIPPING_NOTICE_RPA_WORKER_DISK_RETENTION_DAYS = "7"
SHIPPING_NOTICE_RPA_WORKER_DISK_CLEANUP_INTERVAL_SECONDS = "3600"
SHIPPING_NOTICE_RPA_WORKER_ORPHAN_PROFILE_MAX_AGE_HOURS = "24"
SHIPPING_NOTICE_RPA_WORKER_UPLOAD_ENABLED = "false"
SHIPPING_NOTICE_RPA_WORKER_UPLOAD_CONFIRM_SUBMIT = "false"
}