diff --git a/cucyuqing/cmd/es-sync.py b/cucyuqing/cmd/es-sync.py index 371d29e..9e65c30 100644 --- a/cucyuqing/cmd/es-sync.py +++ b/cucyuqing/cmd/es-sync.py @@ -2,6 +2,7 @@ ES 数据同步脚本 """ +import traceback import asyncio import time import json @@ -219,9 +220,15 @@ async def sync(): async def main(): while True: - await sync() - print("同步完成,等待下一轮同步") - await asyncio.sleep(60) + try: + await sync() + print("同步完成,等待下一轮同步") + except Exception as e: + # 打印出错误堆栈 + traceback.print_exc() + print("同步出错,等待 60 秒后重试", e) + finally: + await asyncio.sleep(60) if __name__ == "__main__":