浏览代码

video_generate_text

luojunhui 3 月之前
父节点
当前提交
dfc7239a42
共有 2 个文件被更改,包括 29 次插入3 次删除
  1. 26 0
      sh/run_article_summary.sh
  2. 3 3
      tasks/article_summary_task.py

+ 26 - 0
sh/run_article_summary.sh

@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# 获取当前日期,格式为 YYYY-MM-DD
+CURRENT_DATE=$(date +%F)
+
+# 日志文件路径,包含日期
+LOG_FILE="/root/luojunhui/logs/article_summary_log_$CURRENT_DATE.txt"
+
+# 重定向整个脚本的输出到带日期的日志文件
+exec >> "$LOG_FILE" 2>&1
+if pgrep -f "python3 run_article_summary.py" > /dev/null
+then
+    echo "$(date '+%Y-%m-%d %H:%M:%S') - run_article_summary.py is running"
+else
+    echo "$(date '+%Y-%m-%d %H:%M:%S') - trying to restart run_article_summary.py"
+    # 切换到指定目录
+    cd /root/luojunhui/LongArticlesJob
+
+    # 激活 Conda 环境
+    source /root/miniconda3/etc/profile.d/conda.sh
+    conda activate tasks
+
+    # 在后台运行 Python 脚本并重定向日志输出
+    nohup python3 run_article_summary.py >> "${LOG_FILE}" 2>&1 &
+    echo "$(date '+%Y-%m-%d %H:%M:%S') - successfully restarted run_article_summary.py"
+fi

+ 3 - 3
tasks/article_summary_task.py

@@ -46,7 +46,7 @@ class ArticleSummaryTask(object):
         select_sql = f"""
             select t1.video_text, t2.audit_video_id
             from video_content_understanding t1 join publish_single_video_source t2 on t1.pq_vid = t2.audit_video_id
-            where t1.status = 2 and t2.bad_status = 0 and t2.extract_status = 1;
+            where t1.status = 2 and t2.bad_status = 0 and t2.extract_status = 0;
         """
         task_list = self.db_client.fetch(select_sql, cursor_type=DictCursor)
         return task_list
@@ -62,11 +62,11 @@ class ArticleSummaryTask(object):
         audit_video_id = task["audit_video_id"]
         # 开始处理,将extract_status更新为101
         update_sql = f"""
-            update publish_single_video_source set extract_status = %s where audit_video_id = %s
+            update publish_single_video_source set extract_status = %s where audit_video_id = %s and extract_status = %s
         """
         affected_rows = self.db_client.save(
             query=update_sql,
-            params=(101, audit_video_id)
+            params=(101, audit_video_id, 0)
         )
         if not affected_rows:
             return