重构任务日志,修复手动停止任务

This commit is contained in:
hanhh
2021-07-04 19:00:02 +08:00
parent c1a3ac6e4d
commit a8a2a54bea
6 changed files with 92 additions and 33 deletions
+8 -6
View File
@@ -148,9 +148,11 @@ get_user_info() {
fi
}
update_cron_status() {
local ids=$1
local status=$2
update_cron() {
local ids="$1"
local status="$2"
local pid="${3:-''}"
local logPath="$4"
local currentTimeStamp=$(date +%s)
local api=$(
curl -s --noproxy "*" "http://localhost:5600/api/crons/status?t=$currentTimeStamp" \
@@ -162,15 +164,15 @@ update_cron_status() {
-H "Origin: http://localhost:5700" \
-H "Referer: http://localhost:5700/crontab" \
-H "Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7" \
--data-raw "{\"ids\":[$ids],\"status\":\"$status\"}" \
--data-raw "{\"ids\":[$ids],\"status\":\"$status\",\"pid\":\"$pid\",\"log_path\":\"$logPath\"}" \
--compressed
)
code=$(echo $api | jq -r .code)
message=$(echo $api | jq -r .message)
if [[ $code == 200 ]]; then
echo -e "更新任务状态成功"
echo -e "更新任务状态成功" | tee -a $log_path
else
echo -e "更新任务状态失败(${message})"
echo -e "更新任务状态失败(${message})" | tee -a $log_path
fi
}