Browse Source

update cicd

15858193327 9 months ago
parent
commit
598e485f7f
3 changed files with 14 additions and 9 deletions
  1. 1 0
      Dockerfile
  2. 2 1
      handleManager.py
  3. 11 8
      main.py

+ 1 - 0
Dockerfile

@@ -14,6 +14,7 @@ WORKDIR /spider_py_client
 # 根据需要, 定义 环境变量
 ENV IP 192.168.70.58
 ENV REFRESHED_AT 2022-07-20
+ENV FAAS_CODE_DIR /data/clientSpider/
 
 # 指定 一个OR多个 卷, 挂载到镜像 (配合后续docker cp使用)
 VOLUME ["/data"]

+ 2 - 1
handleManager.py

@@ -7,6 +7,7 @@ Faas 脚本定位函数
 import pkgutil
 import operator
 import importlib
+import os
 import traceback
 from inspect import getmembers, isclass, isfunction
 
@@ -15,7 +16,7 @@ import json
 # -------------------------------------配置-------------------------------------------------------
 
 handlerFileName = 'spider_result_handler'
-py_code_source_dir = 'F:/codes/python/clientSpider/'
+py_code_source_dir = os.environ.get('FAAS_CODE_DIR', 'F:/codes/python/clientSpider/')
 
 py_code_handler_path_list = [py_code_source_dir + handlerFileName]
 py_code_handler_module_prefix = handlerFileName + '.'

+ 11 - 8
main.py

@@ -2,6 +2,7 @@
 import random
 import time
 import traceback
+import platform
 
 # Press Shift+F10 to execute it or replace it with your code.
 # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
@@ -253,10 +254,6 @@ def schedule_thread_task():
 
 if __name__ == '__main__':
 
-    # 将要发送的消息
-    testMsg = load_mock_msg('m3u8TsTask.json')
-    testMsg = load_mock_msg('normalHtml.json')
-
     # 开子线程 去监听消费消息
     for i in range(8):
         # 实例化的rabbbitmq对象
@@ -272,10 +269,16 @@ if __name__ == '__main__':
     schedule_thread.start()
 
     # 发消息
-    spider_task_queue = connected_to_spider_mq()
+    # 将要发送的消息
+    sys_platform = platform.platform().lower()
+    if "windows" in sys_platform:
+        print("Windows")
+        testMsg = load_mock_msg('m3u8TsTask.json')
+        testMsg = load_mock_msg('normalHtml.json')
+        spider_task_queue = connected_to_spider_mq()
 
-    for i in range(5):
-        #spider_task_queue.publishMsg(json.dumps(testMsg, ensure_ascii=False), delay_ms=2000)
-        print('生产者发送第 {} 个消息成功 '.format(i + 1))
+        for i in range(5):
+            #spider_task_queue.publishMsg(json.dumps(testMsg, ensure_ascii=False), delay_ms=2000)
+            print('生产者发送第 {} 个消息成功 '.format(i + 1))
     print('\n -- 主程序不被阻塞,执行其它操作 --- \n')
     time.sleep(10000)