修复 shell 变量初始化检查,更新 sentry 版本

This commit is contained in:
whyour
2024-08-18 14:19:45 +08:00
parent a743aa8115
commit af5de8372c
14 changed files with 799 additions and 144 deletions
+7 -7
View File
@@ -100,7 +100,7 @@ run_normal() {
if [[ $isJsOrPythonFile == 'false' ]]; then
clear_non_sh_env
fi
$timeoutCmd $which_program $file_param "${script_params[@]}"
$timeoutCmd $which_program $file_param "${script_params[@]:-''}"
}
handle_env_split() {
@@ -143,7 +143,7 @@ run_concurrent() {
export "${env_param}=${array[$i - 1]}"
clear_non_sh_env
fi
eval envParam="${env_param}" numParam="${i}" $timeoutCmd $which_program $file_param "${script_params[@]}" &>$single_log_path &
eval envParam="${env_param}" numParam="${i}" $timeoutCmd $which_program $file_param "${script_params[@]:-''}" &>$single_log_path &
done
wait
@@ -188,7 +188,7 @@ run_designated() {
file_param=${file_param/$relative_path\//}
fi
envParam="${env_param}" numParam="${num_param}" $timeoutCmd $which_program $file_param "${script_params[@]}"
envParam="${env_param}" numParam="${num_param}" $timeoutCmd $which_program $file_param "${script_params[@]:-''}"
}
## 运行其他命令
@@ -210,15 +210,15 @@ run_else() {
check_file() {
isJsOrPythonFile="false"
if [[ $1 == *.js ]] || [[ $1 == *.py ]] || [[ $1 == *.pyc ]] || [[ $1 == *.ts ]]; then
if [[ $1 == *.js ]] || [[ $1 == *.mjs ]] || [[ $1 == *.py ]] || [[ $1 == *.pyc ]] || [[ $1 == *.ts ]]; then
isJsOrPythonFile="true"
fi
if [[ -f $file_env ]]; then
get_env_array
if [[ $isJsOrPythonFile == 'true' ]]; then
PREV_NODE_OPTIONS="${NODE_OPTIONS}"
PREV_PYTHONPATH="${PYTHONPATH}"
if [[ $1 == *.js ]] || [[ $1 == *.ts ]]; then
PREV_NODE_OPTIONS="${NODE_OPTIONS:=}"
PREV_PYTHONPATH="${PYTHONPATH:=}"
if [[ $1 == *.js ]] || [[ $1 == *.ts ]] || [[ $1 == *.mjs ]]; then
export NODE_OPTIONS="${NODE_OPTIONS} -r ${file_preload_js}"
else
export PYTHONPATH="${PYTHONPATH}:${dir_preload}:${dir_config}"
+3 -3
View File
@@ -5,7 +5,7 @@ export dir_root=$QL_DIR
export dir_tmp=$dir_root/.tmp
export dir_data=$dir_root/data
if [[ $QL_DATA_DIR ]]; then
if [[ ${QL_DATA_DIR:=} ]]; then
export dir_data="${QL_DATA_DIR%/}"
fi
@@ -84,7 +84,7 @@ import_config() {
command_timeout_time=${CommandTimeoutTime:-""}
file_extensions=${RepoFileExtensions:-"js py"}
proxy_url=${ProxyUrl:-""}
current_branch=${QL_BRANCH}
current_branch=${QL_BRANCH:-""}
if [[ -n "${DefaultCronRule}" ]]; then
default_cron="${DefaultCronRule}"
@@ -461,7 +461,7 @@ run_task_before() {
run_task_after() {
. $file_task_after "$@"
if [[ $task_after ]]; then
if [[ ${task_after:=} ]]; then
echo -e "\n执行后置命令\n"
eval "$task_after" "$@"
echo -e "\n执行后置命令结束"
+6 -8
View File
@@ -1,6 +1,5 @@
#!/usr/bin/env bash
## 导入通用变量与函数
dir_shell=$QL_DIR/shell
. $dir_shell/share.sh
. $dir_shell/api.sh
@@ -11,7 +10,6 @@ single_hanle() {
exit 1
}
## 选择python3还是node
define_program() {
local file_param=$1
if [[ $file_param == *.js ]] || [[ $file_param == *.mjs ]]; then
@@ -34,7 +32,7 @@ handle_log_path() {
file_param="task"
fi
if [[ -z $ID ]]; then
if [[ -z ${ID:=} ]]; then
ID=$(cat $list_crontab_user | grep -E "$cmd_task.* $file_param" | perl -pe "s|.*ID=(.*) $cmd_task.* $file_param\.*|\1|" | head -1 | awk -F " " '{print $1}')
fi
local suffix=""
@@ -62,17 +60,17 @@ handle_log_path() {
log_dir="${log_dir_tmp%.*}${suffix}"
log_path="$log_dir/$log_time.log"
if [[ $real_log_path ]]; then
if [[ ${real_log_path:=} ]]; then
log_path="$real_log_path"
fi
cmd="2>&1 | tee -a $dir_log/$log_path"
make_dir "$dir_log/$log_dir"
if [[ "$no_tee" == "true" ]]; then
if [[ "${no_tee:=}" == "true" ]]; then
cmd=">> $dir_log/$log_path 2>&1"
fi
if [[ "$real_time" == "true" ]]; then
if [[ "${real_time:=}" == "true" ]]; then
cmd=""
fi
}
@@ -124,8 +122,8 @@ while getopts ":lm:" opt; do
;;
esac
done
[[ $show_log ]] && shift $(($OPTIND - 1))
if [[ $max_time ]]; then
[[ ${show_log:=} ]] && shift $(($OPTIND - 1))
if [[ ${max_time:=} ]]; then
shift $(($OPTIND - 1))
command_timeout_time="$max_time"
fi