From 7b202ee67c42e99008d0d92c53bcf124ec253d9c Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Fri, 24 May 2024 11:50:52 +0800 Subject: [PATCH] f --- cronjob/media/heic_to_jpeg.py | 14 +++++++++---- loop.py | 7 +++++++ start.py | 38 +++++++++++++++++++++++++++++++++++ start.sh | 36 +++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 loop.py create mode 100644 start.py create mode 100644 start.sh diff --git a/cronjob/media/heic_to_jpeg.py b/cronjob/media/heic_to_jpeg.py index ab47154..a29e6ad 100644 --- a/cronjob/media/heic_to_jpeg.py +++ b/cronjob/media/heic_to_jpeg.py @@ -54,12 +54,18 @@ class S: local_path = arr[len(arr) - 1] + ".jpeg" del_images.append(local_path) - ret_save = self.heic_to_jpg_and_save(old_key, local_path) - ret_save_status = ret_save.resp.status - if ret_save_status != 200: - logger.Info("heic_to_jpg_and_save fail, old_key: {}, ret: {}".format(old_key, ret_save_status)) + ret_save_status = 0 + try: + ret_save = self.heic_to_jpg_and_save(old_key, local_path) + ret_save_status = ret_save.resp.status + if ret_save_status != 200: + logger.Info("heic_to_jpg_and_save fail, old_key: {}, ret: {}".format(old_key, ret_save_status)) + continue + except Exception as e: + logger.Info("panic: {}".format(str(e))) continue + # 上传oss ret_upload = self.upload_img_to_oss(local_path, new_key) ret_upload_status = ret_upload.resp.status diff --git a/loop.py b/loop.py new file mode 100644 index 0000000..dca4b75 --- /dev/null +++ b/loop.py @@ -0,0 +1,7 @@ +from lib.all import * + +while True: + time.sleep(0.1) + + res = requests.get("https://testapi.tiefen.fun/test/ip", {}) + print(res.text) diff --git a/start.py b/start.py new file mode 100644 index 0000000..4107b70 --- /dev/null +++ b/start.py @@ -0,0 +1,38 @@ +import time +import os +import subprocess + +duration = 10 * 6000 # 总持续时间,单位为秒 +interval = 1 # 循环间隔,单位为秒 +iterations = duration // interval # 循环次数 +server_status_fd_path = "/Users/erwin/SERVER_STATUS_FD" + +if not os.path.exists(server_status_fd_path): + try: + with open(server_status_fd_path, "w") as f: + print("文件已创建") + f.close() + except Exception as e: + print(str(e)) + +try: + subprocess.run("kill -2 59638", shell=True) +except Exception as e: + print(str(e)) + +# 循环执行 +for i in range(iterations): + time.sleep(interval) + print("执行代码,当前循环次数:", i + 1) + try: + with open(server_status_fd_path, "r") as f: + var = f.read().replace("\r", "").replace("\n", "").replace("\t", "") + if var == "STOP" or var == "": + subprocess.run("nohup /Users/erwin/wishpalv2/service/app/mix/cmd_local/cmd_local &", shell=True) + f.close() + break + f.close() + except Exception as e: + print(str(e)) + + # time.sleep(interval) # 等待指定的间隔时间 diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..5687276 --- /dev/null +++ b/start.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +duration=$((30)) # 总持续时间,单位为秒 +interval=1 # 循环间隔,单位为秒 +iterations=$((duration / interval)) # 循环次数 +server_status_fd_path="/app/SERVER_STATUS_FD" + +if [ ! -f "$server_status_fd_path" ]; then + touch "$server_status_fd_path" + echo "文件已创建" +fi + + +pid=$(ps -ef | grep wishpal-ironfan | grep -v grep | awk -F " " '{print $2}') +echo $pid +kill -2 $pid + +systemctl stop wishpal-ironfan + +# 循环执行 +for ((i=0; i