Skip to content

Commit

Permalink
修复shell本地开发兼容性
Browse files Browse the repository at this point in the history
  • Loading branch information
whyour committed Jun 9, 2022
1 parent b009d3e commit a7b5a0f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .env.example
Expand Up @@ -7,6 +7,6 @@ LOG_LEVEL='debug'

SECRET='whyour'

QINIU_AK = ''
QINIU_SK = ''
QINIU_SCOPE = ''
QINIU_AK=''
QINIU_SK=''
QINIU_SCOPE=''
4 changes: 4 additions & 0 deletions back/loaders/initFile.ts
Expand Up @@ -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');
};
16 changes: 11 additions & 5 deletions shell/task.sh
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand All @@ -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)
Expand Down

0 comments on commit a7b5a0f

Please sign in to comment.