修复shell本地开发兼容性

This commit is contained in:
whyour 2022-06-09 12:10:41 +08:00
parent b009d3e3fd
commit a7b5a0f4c5
3 changed files with 18 additions and 8 deletions

View File

@ -7,6 +7,6 @@ LOG_LEVEL='debug'
SECRET='whyour'
QINIU_AK = ''
QINIU_SK = ''
QINIU_SCOPE = ''
QINIU_AK=''
QINIU_SK=''
QINIU_SCOPE=''

View File

@ -64,5 +64,9 @@ export default async () => {
dotenv.config({ path: confFile });
// 声明QL_DIR环境变量
const qlHomePath = path.join(__dirname, '../../');
process.env.QL_DIR = qlHomePath;
Logger.info('✌️ Init file down');
};

View File

@ -118,12 +118,13 @@ run_normal() {
cd ${relative_path}
file_param=${file_param/$relative_path\//}
fi
eval timeout -k 10s $command_timeout_time $which_program $file_param $cmd
eval $timeoutCmd $which_program $file_param $cmd
eval . $file_task_after "$@" $cmd
local end_time=$(date '+%Y-%m-%d %H:%M:%S')
local end_timestamp=$(date "+%s")
local diff_time=$(( $end_timestamp - $begin_timestamp ))
local diff_time=$(expr $end_timestamp - $begin_timestamp)
[[ $id ]] && update_cron "\"$id\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time"
eval echo -e "\\\n\#\# 执行结束... $end_time 耗时 $diff_time" $cmd
}
@ -196,7 +197,7 @@ run_concurrent() {
for i in "${!array[@]}"; do
export ${env_param}=${array[i]}
single_log_path="$dir_log/$log_dir/${single_log_time}_$((i + 1)).log"
timeout -k 10s $command_timeout_time $which_program $file_param &>$single_log_path &
eval $timeoutCmd $which_program $file_param &>$single_log_path &
done
wait
@ -274,7 +275,7 @@ run_designated() {
cd ${relative_path}
file_param=${file_param/$relative_path\//}
fi
eval timeout -k 10s $command_timeout_time $which_program $file_param $cmd
eval $timeoutCmd $which_program $file_param $cmd
eval . $file_task_after "$@" $cmd
local end_time=$(date '+%Y-%m-%d %H:%M:%S')
@ -325,7 +326,7 @@ run_else() {
fi
shift
eval timeout -k 10s $command_timeout_time $which_program "$file_param" "$@" $cmd
eval $timeoutCmd $which_program "$file_param" "$@" $cmd
eval . $file_task_after "$file_param" "$@" $cmd
local end_time=$(date '+%Y-%m-%d %H:%M:%S')
@ -348,6 +349,11 @@ main() {
done
[[ "$show_log" == "true" ]] && shift $(($OPTIND - 1))
timeoutCmd=""
if type timeout &>/dev/null; then
timeoutCmd="timeout -k 10s $command_timeout_time "
fi
if [[ $1 == *.js ]] || [[ $1 == *.py ]] || [[ $1 == *.sh ]] || [[ $1 == *.ts ]]; then
case $# in
1)