mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-27 14:46:06 +08:00
完善ql repo命令
This commit is contained in:
parent
34775dd14d
commit
bde7d6be03
|
@ -31,7 +31,11 @@ const run = async () => {
|
||||||
task.status !== CrontabStatus.disabled
|
task.status !== CrontabStatus.disabled
|
||||||
) {
|
) {
|
||||||
schedule.scheduleJob(task.schedule, function () {
|
schedule.scheduleJob(task.schedule, function () {
|
||||||
exec(task.command);
|
let command = task.command as string;
|
||||||
|
if (!command.startsWith('task ')) {
|
||||||
|
command = `task ${command}`;
|
||||||
|
}
|
||||||
|
exec(command);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,10 +124,11 @@ export default class CronService {
|
||||||
fs.writeFileSync(logFile, `开始执行...\n\n${new Date().toString()}\n`);
|
fs.writeFileSync(logFile, `开始执行...\n\n${new Date().toString()}\n`);
|
||||||
|
|
||||||
let cmdStr = res.command;
|
let cmdStr = res.command;
|
||||||
if (res.command.startsWith('js') && !res.command.endsWith('now')) {
|
if (!res.command.startsWith('task')) {
|
||||||
cmdStr = `${res.command} now`;
|
cmdStr = `task ${cmdStr}`;
|
||||||
} else if (/&& (.*) >>/.test(res.command)) {
|
}
|
||||||
cmdStr = res.command.match(/&& (.*) >>/)[1];
|
if (res.command.endsWith('.js')) {
|
||||||
|
cmdStr = `${cmdStr} now`;
|
||||||
}
|
}
|
||||||
const cmd = spawn(cmdStr, { shell: true });
|
const cmd = spawn(cmdStr, { shell: true });
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
dir_shell=/ql/shell
|
dir_shell=/ql/shell
|
||||||
. $dir_shell/share.sh
|
. $dir_shell/share.sh
|
||||||
|
|
||||||
## 导入配置文件
|
|
||||||
import_config
|
|
||||||
|
|
||||||
## 生成pt_pin清单
|
## 生成pt_pin清单
|
||||||
gen_pt_pin_array () {
|
gen_pt_pin_array () {
|
||||||
local tmp1 tmp2 i pt_pin_temp
|
local tmp1 tmp2 i pt_pin_temp
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
dir_shell=/ql/shell
|
dir_shell=/ql/shell
|
||||||
. $dir_shell/share.sh
|
. $dir_shell/share.sh
|
||||||
|
|
||||||
## 导入配置文件
|
|
||||||
import_config
|
|
||||||
|
|
||||||
days=$1
|
days=$1
|
||||||
|
|
||||||
## 删除运行js脚本的旧日志
|
## 删除运行js脚本的旧日志
|
||||||
|
|
|
@ -11,6 +11,7 @@ dir_db=$dir_root/db
|
||||||
dir_manual_log=$dir_root/manual_log
|
dir_manual_log=$dir_root/manual_log
|
||||||
dir_list_tmp=$dir_log/.tmp
|
dir_list_tmp=$dir_log/.tmp
|
||||||
dir_code=$dir_log/code
|
dir_code=$dir_log/code
|
||||||
|
dir_update_log=$dir_log/update
|
||||||
|
|
||||||
## 文件
|
## 文件
|
||||||
file_config_sample=$dir_sample/config.sample.sh
|
file_config_sample=$dir_sample/config.sample.sh
|
||||||
|
@ -143,6 +144,7 @@ fix_config () {
|
||||||
make_dir $dir_scripts
|
make_dir $dir_scripts
|
||||||
make_dir $dir_list_tmp
|
make_dir $dir_list_tmp
|
||||||
make_dir $dir_raw
|
make_dir $dir_raw
|
||||||
|
make_dir $dir_update_log
|
||||||
|
|
||||||
if [ ! -s $file_config_user ]; then
|
if [ ! -s $file_config_user ]; then
|
||||||
echo -e "复制一份 $file_config_sample 为 $file_config_user,随后请按注释编辑你的配置文件:$file_config_user\n"
|
echo -e "复制一份 $file_config_sample 为 $file_config_user,随后请按注释编辑你的配置文件:$file_config_user\n"
|
||||||
|
|
|
@ -59,7 +59,6 @@ random_delay () {
|
||||||
|
|
||||||
## scripts目录下所有可运行脚本数组
|
## scripts目录下所有可运行脚本数组
|
||||||
gen_array_scripts () {
|
gen_array_scripts () {
|
||||||
import_config
|
|
||||||
local dir_current=$(pwd)
|
local dir_current=$(pwd)
|
||||||
local i="-1"
|
local i="-1"
|
||||||
cd $dir_scripts
|
cd $dir_scripts
|
||||||
|
@ -79,13 +78,17 @@ usage () {
|
||||||
define_cmd
|
define_cmd
|
||||||
gen_array_scripts
|
gen_array_scripts
|
||||||
echo -e "\ntask命令运行本程序自动添加进crontab的脚本,需要输入脚本的绝对路径或去掉 “$dir_scripts/” 目录后的相对路径(定时任务中请写作相对路径),用法为:"
|
echo -e "\ntask命令运行本程序自动添加进crontab的脚本,需要输入脚本的绝对路径或去掉 “$dir_scripts/” 目录后的相对路径(定时任务中请写作相对路径),用法为:"
|
||||||
echo -e "1.$cmd_task <js_path> # 依次执行,如果设置了随机延迟并且当时时间不在0-2、30-31、59分内,将随机延迟一定秒数"
|
echo -e "1.$cmd_task <file_name> # 依次执行,如果设置了随机延迟并且当时时间不在0-2、30-31、59分内,将随机延迟一定秒数"
|
||||||
echo -e "2.$cmd_task <js_path> now # 依次执行,无论是否设置了随机延迟,均立即运行,前台会输出日志,同时记录在日志文件中"
|
echo -e "2.$cmd_task <file_name> now # 依次执行,无论是否设置了随机延迟,均立即运行,前台会输出日志,同时记录在日志文件中"
|
||||||
echo -e "3.$cmd_task <js_path> conc # 并发执行,无论是否设置了随机延迟,均立即运行,前台不产生日志,直接记录在日志文件中"
|
echo -e "3.$cmd_task <file_name> conc # 并发执行,无论是否设置了随机延迟,均立即运行,前台不产生日志,直接记录在日志文件中"
|
||||||
echo -e "\n当前有以下脚本可以运行(已省略路径 “$dir_scripts/” ):"
|
if [[ ${#array_scripts[*]} -gt 0 ]]; then
|
||||||
|
echo -e "\n当前有以下脚本可以运行:"
|
||||||
for ((i=0; i<${#array_scripts[*]}; i++)); do
|
for ((i=0; i<${#array_scripts[*]}; i++)); do
|
||||||
echo -e "$(($i + 1)). ${array_scripts_name[i]}:${array_scripts[i]}"
|
echo -e "$(($i + 1)). ${array_scripts_name[i]}:${array_scripts[i]}"
|
||||||
done
|
done
|
||||||
|
else
|
||||||
|
echo -e "\n暂无脚本可以执行"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## run nohup,$1:文件名,不含路径,带后缀
|
## run nohup,$1:文件名,不含路径,带后缀
|
||||||
|
@ -98,14 +101,17 @@ run_nohup () {
|
||||||
run_normal () {
|
run_normal () {
|
||||||
local p1=$1
|
local p1=$1
|
||||||
cd $dir_scripts
|
cd $dir_scripts
|
||||||
import_config
|
|
||||||
define_program "$p1"
|
define_program "$p1"
|
||||||
combine_all
|
combine_all
|
||||||
|
if [[ $p1 == *.js ]]; then
|
||||||
if [[ $AutoHelpOther == true ]] && [[ $(ls $dir_code) ]]; then
|
if [[ $AutoHelpOther == true ]] && [[ $(ls $dir_code) ]]; then
|
||||||
local latest_log=$(ls -r $dir_code | head -1)
|
local latest_log=$(ls -r $dir_code | head -1)
|
||||||
. $dir_code/$latest_log
|
. $dir_code/$latest_log
|
||||||
fi
|
fi
|
||||||
[[ $# -eq 1 ]] && random_delay
|
if [[ $# -eq 1 ]]; then
|
||||||
|
random_delay
|
||||||
|
fi
|
||||||
|
fi
|
||||||
log_time=$(date "+%Y-%m-%d-%H-%M-%S")
|
log_time=$(date "+%Y-%m-%d-%H-%M-%S")
|
||||||
log_path="$dir_log/$p1/$log_time.log"
|
log_path="$dir_log/$p1/$log_time.log"
|
||||||
make_dir "$dir_log/$p1"
|
make_dir "$dir_log/$p1"
|
||||||
|
@ -117,7 +123,6 @@ run_normal () {
|
||||||
run_concurrent () {
|
run_concurrent () {
|
||||||
local p1=$1
|
local p1=$1
|
||||||
cd $dir_scripts
|
cd $dir_scripts
|
||||||
import_config
|
|
||||||
define_program "$p1"
|
define_program "$p1"
|
||||||
make_dir $dir_log/$p1
|
make_dir $dir_log/$p1
|
||||||
log_time=$(date "+%Y-%m-%d-%H-%M-%S.%N")
|
log_time=$(date "+%Y-%m-%d-%H-%M-%S.%N")
|
||||||
|
|
|
@ -306,7 +306,12 @@ gen_list_repo() {
|
||||||
fi
|
fi
|
||||||
for file in ${files}; do
|
for file in ${files}; do
|
||||||
filename=$(basename $file)
|
filename=$(basename $file)
|
||||||
|
local non_scripts=$(echo $filename | egrep jd | egrep -v "jd_")
|
||||||
|
if [[ -z $non_scripts ]]; then
|
||||||
|
cp -f $file $dir_scripts/${filename}
|
||||||
|
else
|
||||||
cp -f $file $dir_scripts/${author}_${filename}
|
cp -f $file $dir_scripts/${author}_${filename}
|
||||||
|
fi
|
||||||
echo ${author}_${filename} >>$list_own_scripts
|
echo ${author}_${filename} >>$list_own_scripts
|
||||||
done
|
done
|
||||||
grep -E "$cmd_task $author" $list_crontab_user | perl -pe "s|.*ID=(.*) $cmd_task ($author_.*)\.*|\2|" | sort -u >$list_own_user
|
grep -E "$cmd_task $author" $list_crontab_user | perl -pe "s|.*ID=(.*) $cmd_task ($author_.*)\.*|\2|" | sort -u >$list_own_user
|
||||||
|
@ -315,7 +320,6 @@ gen_list_repo() {
|
||||||
|
|
||||||
## 重新编译qinglong
|
## 重新编译qinglong
|
||||||
restart_qinglong() {
|
restart_qinglong() {
|
||||||
echo -e "--------------------------------------------------------------\n"
|
|
||||||
update_qinglong
|
update_qinglong
|
||||||
if [[ $exit_status -eq 0 ]]; then
|
if [[ $exit_status -eq 0 ]]; then
|
||||||
echo -e "重新编译青龙...\n"
|
echo -e "重新编译青龙...\n"
|
||||||
|
@ -343,7 +347,6 @@ main() {
|
||||||
local p4=$4
|
local p4=$4
|
||||||
log_time=$(date "+%Y-%m-%d-%H-%M-%S")
|
log_time=$(date "+%Y-%m-%d-%H-%M-%S")
|
||||||
log_path="$dir_log/update/${log_time}_$p1.log"
|
log_path="$dir_log/update/${log_time}_$p1.log"
|
||||||
make_dir "$dir_log/update"
|
|
||||||
case $p1 in
|
case $p1 in
|
||||||
update)
|
update)
|
||||||
update_qinglong | tee $log_path
|
update_qinglong | tee $log_path
|
||||||
|
@ -353,16 +356,29 @@ main() {
|
||||||
restart_qinglong | tee $log_path
|
restart_qinglong | tee $log_path
|
||||||
;;
|
;;
|
||||||
repo)
|
repo)
|
||||||
|
local name=$(echo "${p2##*/}" | awk -F "." '{print $1}')
|
||||||
|
log_path="$dir_log/update/${log_time}_$name.log"
|
||||||
|
if [[ -n $p2 ]]; then
|
||||||
update_repo "$p2" "$p3" "$p4" | tee $log_path
|
update_repo "$p2" "$p3" "$p4" | tee $log_path
|
||||||
|
else
|
||||||
|
echo -e "命令输入错误...\n"
|
||||||
|
usage
|
||||||
;;
|
;;
|
||||||
raw)
|
raw)
|
||||||
|
local name=$(echo "${p2##*/}" | awk -F "." '{print $1}')
|
||||||
|
log_path="$dir_log/update/${log_time}_$name.log"
|
||||||
|
if [[ -n $p2 ]]; then
|
||||||
update_raw "$p2" | tee $log_path
|
update_raw "$p2" | tee $log_path
|
||||||
|
else
|
||||||
|
echo -e "命令输入错误...\n"
|
||||||
|
usage
|
||||||
|
;;
|
||||||
;;
|
;;
|
||||||
rmlog)
|
rmlog)
|
||||||
source $dir_shell/rmlog.sh "$p2" | tee $log_path
|
. $dir_shell/rmlog.sh "$p2" | tee $log_path
|
||||||
;;
|
;;
|
||||||
code)
|
code)
|
||||||
source $dir_shell/code.sh
|
. $dir_shell/code.sh
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "命令输入错误...\n"
|
echo -e "命令输入错误...\n"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user