This commit is contained in:
lwl0608 2024-05-24 11:50:52 +08:00
parent a608d4af29
commit 7b202ee67c
4 changed files with 91 additions and 4 deletions

View File

@ -54,12 +54,18 @@ class S:
local_path = arr[len(arr) - 1] + ".jpeg" local_path = arr[len(arr) - 1] + ".jpeg"
del_images.append(local_path) del_images.append(local_path)
ret_save = self.heic_to_jpg_and_save(old_key, local_path) ret_save_status = 0
ret_save_status = ret_save.resp.status try:
if ret_save_status != 200: ret_save = self.heic_to_jpg_and_save(old_key, local_path)
logger.Info("heic_to_jpg_and_save fail, old_key: {}, ret: {}".format(old_key, ret_save_status)) 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 continue
# 上传oss # 上传oss
ret_upload = self.upload_img_to_oss(local_path, new_key) ret_upload = self.upload_img_to_oss(local_path, new_key)
ret_upload_status = ret_upload.resp.status ret_upload_status = ret_upload.resp.status

7
loop.py Normal file
View File

@ -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)

38
start.py Normal file
View File

@ -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) # 等待指定的间隔时间

36
start.sh Normal file
View File

@ -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<iterations; i++)); do
echo "执行代码,当前循环次数: $((i + 1))"
if [ -f "$server_status_fd_path" ]; then
var=$(cat "$server_status_fd_path" | tr -d '\r\n\t')
echo $var
if [ "$var" = "STOP" ] || [ -z "$var" ]; then
systemctl start wishpal-ironfan
break
fi
fi
sleep $interval # 等待指定的间隔时间
done