mirror of
https://github.com/whyour/qinglong.git
synced 2026-06-30 20:35:09 +08:00
增加自动运行任务时任务状态展示
1. 添加bot远程地址 2. 增加文件后缀配置 3. 增加定时任务页数缓存
This commit is contained in:
@@ -147,3 +147,29 @@ get_user_info() {
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
update_cron_status() {
|
||||
local ids=$1
|
||||
local status=$2
|
||||
local currentTimeStamp=$(date +%s)
|
||||
local api=$(
|
||||
curl -s "http://localhost:5700/api/crons/status?t=$currentTimeStamp" \
|
||||
-X 'PUT' \
|
||||
-H "Accept: application/json" \
|
||||
-H "Authorization: Bearer $token" \
|
||||
-H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36" \
|
||||
-H "Content-Type: application/json;charset=UTF-8" \
|
||||
-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\"}" \
|
||||
--compressed
|
||||
)
|
||||
code=$(echo $api | jq -r .code)
|
||||
message=$(echo $api | jq -r .message)
|
||||
if [[ $code == 200 ]]; then
|
||||
echo -e "成功"
|
||||
else
|
||||
echo -e "失败(${message})"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
## 导入通用变量与函数
|
||||
dir_shell=/ql/shell
|
||||
. $dir_shell/share.sh
|
||||
url="${github_proxy_url}https://github.com/SuMaiKaDe/bot.git"
|
||||
repo_path="${dir_repo}/dockerbot"
|
||||
|
||||
echo -e "\n1、安装bot依赖...\n"
|
||||
@@ -10,6 +11,13 @@ apk --no-cache add -f zlib-dev gcc jpeg-dev python3-dev musl-dev freetype-dev
|
||||
echo -e "\nbot依赖安装成功...\n"
|
||||
|
||||
echo -e "2、下载bot所需文件...\n"
|
||||
if [ -d ${repo_path}/.git ]; then
|
||||
git_pull_scripts ${repo_path}
|
||||
else
|
||||
rm -rf ${repo_path}
|
||||
git_clone_scripts ${url} ${repo_path} "main"
|
||||
fi
|
||||
|
||||
cp -rf "$repo_path/jbot" $dir_root
|
||||
if [[ ! -f "$dir_root/config/bot.json" ]]; then
|
||||
cp -f "$repo_path/config/bot.json" "$dir_root/config"
|
||||
|
||||
@@ -62,6 +62,7 @@ import_config() {
|
||||
command_timeout_time=${CommandTimeoutTime:-"1h"}
|
||||
github_proxy_url=${GithubProxyUrl:-""}
|
||||
block_cookie=${TempBlockCookie:-""}
|
||||
file_extensions=${RepoFileExtensions:-"js py"}
|
||||
}
|
||||
|
||||
## 创建目录,$1:目录的绝对路径
|
||||
|
||||
@@ -120,6 +120,10 @@ run_normal() {
|
||||
log_dir="$dir_log/${log_dir_tmp%%.*}"
|
||||
log_path="$log_dir/$log_time.log"
|
||||
make_dir "$log_dir"
|
||||
|
||||
local id=$(cat $list_crontab_user | grep -E "$cmd_task $p1$" | perl -pe "s|.*ID=(.*) $cmd_task $p1$|\1|" | xargs | sed 's/ /","/g')
|
||||
local status="0" ## 0 任务运行中
|
||||
update_cron_status "\"$id\"" $status
|
||||
timeout $command_timeout_time $which_program $p1 2>&1 | tee $log_path
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -357,7 +357,12 @@ gen_list_repo() {
|
||||
rm -f $dir_list_tmp/${repo}*.list >/dev/null 2>&1
|
||||
|
||||
cd ${repo_path}
|
||||
files=$(find . -name "*.js" | sed 's/^..//')
|
||||
|
||||
local cmd="find ."
|
||||
for extension in $file_extensions; do
|
||||
cmd="${cmd} -o -name \"*.${extension}\""
|
||||
done
|
||||
files=$($cmd | sed 's/^..//')
|
||||
if [[ $path ]]; then
|
||||
files=$(echo "$files" | egrep $path)
|
||||
fi
|
||||
@@ -365,7 +370,7 @@ gen_list_repo() {
|
||||
files=$(echo "$files" | egrep -v $blackword)
|
||||
fi
|
||||
if [[ $dependence ]]; then
|
||||
find . -name "*.js" | sed 's/^..//' | egrep $dependence | xargs -i cp {} $dir_scripts
|
||||
$cmd | sed 's/^..//' | egrep $dependence | xargs -i cp {} $dir_scripts
|
||||
fi
|
||||
for file in ${files}; do
|
||||
filename=$(basename $file)
|
||||
|
||||
Reference in New Issue
Block a user