瀏覽代碼

增加进程监测代码上线

五个定时任务取消等待时间
罗俊辉 7 月之前
父節點
當前提交
09bbffe2d9

+ 1 - 0
coldStartTasks/publishCategoryArticles.py

@@ -2,3 +2,4 @@
 @author: luojunhui
 品类文章发布到aigc系统
 """
+

+ 6 - 6
getOffVideosDaily.py

@@ -240,9 +240,9 @@ if __name__ == '__main__':
 
     while True:
         schedule.run_pending()
-        time.sleep(60)
-        log(
-            task="getOffVideos",
-            function="main",
-            message="自动下架视频任务正常执行"
-        )
+        time.sleep(0.5)
+        # log(
+        #     task="getOffVideos",
+        #     function="main",
+        #     message="自动下架视频任务正常执行"
+        # )

+ 6 - 6
migrateRootSourceId.py

@@ -146,9 +146,9 @@ if __name__ == '__main__':
     schedule.every().day.at("01:00").do(Functions().job_with_thread, source_id_job)
     while True:
         schedule.run_pending()
-        time.sleep(60)
-        log(
-            task="migrateRootSourceId",
-            function="main",
-            message="迁移 source_id 任务正常执行"
-        )
+        time.sleep(0.5)
+        # log(
+        #     task="migrateRootSourceId",
+        #     function="main",
+        #     message="迁移 source_id 任务正常执行"
+        # )

+ 89 - 0
threadAliveBot.py

@@ -0,0 +1,89 @@
+"""
+@author: luojunhui
+@description: 监测进程是否 alive in every 10 minutes
+"""
+import datetime
+import subprocess
+import time
+
+from applications import bot
+
+
+def threadMonitor():
+    """
+    校验进程是否 alive
+    :return:
+    """
+    result = subprocess.run(
+        ["ps", "aux"],
+        stdout=subprocess.PIPE,
+        text=True
+    )
+
+    # 获取命令输出结果
+    output = result.stdout
+
+    # filter
+    get_off_job = [line for line in output.splitlines() if 'python3 getOffVideosDaily.py' in line]
+
+    migrate_source_id_job = [line for line in output.splitlines() if 'python3 migrateRootSourceId.py' in line]
+
+    updateAccountAvgDaily = [line for line in output.splitlines() if 'python3 updateAccountAvgDaily.py' in line]
+
+    updateMinigramInfoDaily = [line for line in output.splitlines() if 'python3 updateMinigramInfoDaily.py' in line]
+
+    updatePublishedMsgDaily = [line for line in output.splitlines() if 'python3 updatePublishedMsgDaily.py' in line]
+
+    if not get_off_job:
+        bot(
+            title="定时任务进程异常挂掉",
+            detail={
+                "Job": "GetOffVideosJob",
+                "Time": datetime.datetime.now().__str__()
+            }
+        )
+
+    if not migrate_source_id_job:
+        bot(
+            title="定时任务进程异常挂掉",
+            detail={
+                "Job": "migrate_source_id_job",
+                "Time": datetime.datetime.now().__str__()
+            }
+        )
+
+    if not updateAccountAvgDaily:
+        bot(
+            title="定时任务进程异常挂掉",
+            detail={
+                "Job": "updateAccountAvgDaily",
+                "Time": datetime.datetime.now().__str__()
+            }
+        )
+
+    if not updateMinigramInfoDaily:
+        bot(
+            title="定时任务进程异常挂掉",
+            detail={
+                "Job": "updateMinigramInfoDaily",
+                "Time": datetime.datetime.now().__str__()
+            }
+        )
+
+    if not updatePublishedMsgDaily:
+        bot(
+            title="定时任务进程异常挂掉",
+            detail={
+                "Job": "updatePublishedMsgDaily",
+                "Time": datetime.datetime.now().__str__()
+            }
+        )
+
+
+if __name__ == '__main__':
+    while True:
+        threadMonitor()
+        time.sleep(60 * 10)
+
+
+

+ 7 - 7
updateAccountAvgDaily.py

@@ -290,13 +290,13 @@ def updateAvgJob():
 
 if __name__ == "__main__":
 
-    schedule.every().day.at("22:30").do(Functions().job_with_thread, updateAvgJob)
+    schedule.every().day.at("22:00").do(Functions().job_with_thread, updateAvgJob)
 
     while True:
         schedule.run_pending()
-        time.sleep(60)
-        log(
-            task="updateAccountAvgDaily",
-            function="main",
-            message="更新账号均值任务正常执行"
-        )
+        time.sleep(0.5)
+        # log(
+        #     task="updateAccountAvgDaily",
+        #     function="main",
+        #     message="更新账号均值任务正常执行"
+        # )

+ 6 - 6
updateMinigramInfoDaily.py

@@ -331,9 +331,9 @@ if __name__ == '__main__':
 
     while True:
         schedule.run_pending()
-        time.sleep(60)
-        log(
-            task="updateMinigramInfoDaily",
-            function="main",
-            message="更新文章小程序信息任务正常执行"
-        )
+        time.sleep(0.5)
+        # log(
+        #     task="updateMinigramInfoDaily",
+        #     function="main",
+        #     message="更新文章小程序信息任务正常执行"
+        # )

+ 7 - 7
updatePublishedMsgDaily.py

@@ -367,14 +367,14 @@ if __name__ == '__main__':
 
     schedule.every().day.at("20:50").do(job_with_thread, updateJob)
 
-    schedule.every().day.at("22:00").do(job_with_thread, checkJob)
+    schedule.every().day.at("21:30").do(job_with_thread, checkJob)
 
     while True:
         schedule.run_pending()
-        time.sleep(60)
-        log(
-            task="updatePublishedMsgDaily",
-            function="main",
-            message="更新公众号文章信息任务正常执行"
-        )
+        time.sleep(0.5)
+        # log(
+        #     task="updatePublishedMsgDaily",
+        #     function="main",
+        #     message="更新公众号文章信息任务正常执行"
+        # )