feat(shipping-notice): 增加 RPA Worker 心跳上报与状态查询功能

This commit is contained in:
hugo committed 2026-07-12 12:52:01 +08:00
1 parent c3f05ba96b
commit 5a147c4d85
49 files changed
+4032 -1500

No files matched your search

+17
View File
@@ -61,6 +61,7 @@ import dsv_navigation # noqa: E402
import dsv_report_export # noqa: E402
from dsv_report_export import NoInventoryDataError # noqa: E402
import dsv_session # noqa: E402
import freight_rpa_heartbeat # noqa: E402
# 测试与 smoke 向后兼容 re-export
_maybe_auto_login_dsv = dsv_session.maybe_auto_login_dsv
@@ -1101,10 +1102,13 @@ def _scan_triggers(trigger_dir: Path, handler, extra_args: tuple = ()) -> None:
for path in sorted(trigger_dir.glob("*.json")):
if not path.is_file():
continue
freight_rpa_heartbeat.set_worker_runtime_status("busy")
try:
handler(path, *extra_args)
except Exception as exc:
print(f"[error] {path.name}: {exc}", file=sys.stderr)
finally:
freight_rpa_heartbeat.set_worker_runtime_status("idle")
def main() -> None:
@@ -1125,7 +1129,20 @@ def main() -> None:
print(f" drop={drop_dir}")
print(f" queue={upload_queue_dir}")
last_heartbeat_mono = 0.0
last_heartbeat_mono = freight_rpa_heartbeat.maybe_send_heartbeat(
trigger_dir=inv_trigger_dir,
drop_dir=drop_dir,
last_sent_mono=last_heartbeat_mono,
force=True,
)
while True:
last_heartbeat_mono = freight_rpa_heartbeat.maybe_send_heartbeat(
trigger_dir=inv_trigger_dir,
drop_dir=drop_dir,
last_sent_mono=last_heartbeat_mono,
)
_scan_triggers(inv_trigger_dir, _handle_inventory_trigger, (drop_dir, inv_processed))
_scan_triggers(upload_trigger_dir, _handle_upload_trigger, (upload_processed,))
time.sleep(poll)