mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 14:56:07 +08:00
task 命令支持给脚本传参,使用 -- 分割,后面的参数都会传给脚本
例如 task x.js -n whyour,脚本就能接收到参数 -n whyour
This commit is contained in:
parent
5055045d22
commit
9fb9b3d121
67
README-en.md
67
README-en.md
|
@ -36,6 +36,7 @@ Timed task management platform supporting Python3, JavaScript, Shell, Typescript
|
||||||
- Support cell phone operation
|
- Support cell phone operation
|
||||||
|
|
||||||
## Version
|
## Version
|
||||||
|
|
||||||
### docker
|
### docker
|
||||||
|
|
||||||
The `latest` image is built on `alpine` and the `debian` image is built on `debian-slim`. If you need to use a dependency that is not supported by `alpine`, it is recommended that you use the `debian` image.
|
The `latest` image is built on `alpine` and the `debian` image is built on `debian-slim`. If you need to use a dependency that is not supported by `alpine`, it is recommended that you use the `debian` image.
|
||||||
|
@ -118,9 +119,30 @@ export QL_DATA_DIR=""
|
||||||
qinglong
|
qinglong
|
||||||
```
|
```
|
||||||
|
|
||||||
## Use
|
## Built-in commands
|
||||||
|
|
||||||
1. built-in commands
|
1. task
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Execute in sequence, if a random delay is set, it will be randomly delayed by a certain number of seconds
|
||||||
|
task <file_path>
|
||||||
|
# Execute in sequence, regardless of whether a random delay is set, all run immediately,
|
||||||
|
# and the foreground will output the day, while recorded in the log file
|
||||||
|
task <file_path> now
|
||||||
|
# Concurrent execution, regardless of whether a random delay is set, are run immediately,
|
||||||
|
# the foreground does not generate the day, directly recorded in the log file, and can be specified account execution
|
||||||
|
task <file_path> conc <env_name> <account_number>(Optional)
|
||||||
|
# Specify the account to execute and run immediately regardless of whether a random delay is set
|
||||||
|
task <file_path> desi <env_name> <account_number>
|
||||||
|
# Set task timeout
|
||||||
|
task -m <max_time> <file_path>
|
||||||
|
# Print task log in real time, no need to carry this parameter when creating timed tasks
|
||||||
|
task -l <file_path>
|
||||||
|
# Use -- to split, -- followed by a parameter that is passed to the script, as in the following example, the script receives the parameter -u whyour -p password
|
||||||
|
task <file_path> -- -u whyour -p password
|
||||||
|
```
|
||||||
|
|
||||||
|
1. ql
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Update and restart Green Dragon
|
# Update and restart Green Dragon
|
||||||
|
@ -141,36 +163,21 @@ ql check
|
||||||
ql resetlet
|
ql resetlet
|
||||||
# Disable two-step login
|
# Disable two-step login
|
||||||
ql resettfa
|
ql resettfa
|
||||||
|
|
||||||
# Execute in sequence, if a random delay is set, it will be randomly delayed by a certain number of seconds
|
|
||||||
task <file_path>
|
|
||||||
# Execute in sequence, regardless of whether a random delay is set, all run immediately,
|
|
||||||
# and the foreground will output the day, while recorded in the log file
|
|
||||||
task <file_path> now
|
|
||||||
# Concurrent execution, regardless of whether a random delay is set, are run immediately,
|
|
||||||
# the foreground does not generate the day, directly recorded in the log file, and can be specified account execution
|
|
||||||
task <file_path> conc <env_name> <account_number>(Optional)
|
|
||||||
# Specify the account to execute and run immediately regardless of whether a random delay is set
|
|
||||||
task <file_path> desi <env_name> <account_number>
|
|
||||||
# Set task timeout
|
|
||||||
task -m <max_time> <file_path>
|
|
||||||
# Print task log in real time, no need to carry this parameter when creating timed tasks
|
|
||||||
task -l <file_path>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
2. parameter description
|
1. parameter description
|
||||||
|
|
||||||
* file_url: Script address
|
- file_url: Script address
|
||||||
* repo_url: Repository address
|
- repo_url: Repository address
|
||||||
* whitelist: The whitelist when pulling the repository, i.e., the string contained in the path of the script to be pulled
|
- whitelist: The whitelist when pulling the repository, i.e., the string contained in the path of the script to be pulled
|
||||||
* blacklist: Blacklisting when pulling repositories, i.e. strings that are not included in the path of the script to be pulled
|
- blacklist: Blacklisting when pulling repositories, i.e. strings that are not included in the path of the script to be pulled
|
||||||
* dependence: Pulling the dependencies needed for the repository will be copied directly from the repository to the repository directory under scripts, regardless of the blacklist
|
- dependence: Pulling the dependencies needed for the repository will be copied directly from the repository to the repository directory under scripts, regardless of the blacklist
|
||||||
* branch: Pull the branch of the repository
|
- branch: Pull the branch of the repository
|
||||||
* days: Number of days of logs to be kept
|
- days: Number of days of logs to be kept
|
||||||
* file_path: File path for task execution
|
- file_path: File path for task execution
|
||||||
* env_name: The name of the environment variable that needs to be concurrent or specified at the time of task execution
|
- env_name: The name of the environment variable that needs to be concurrent or specified at the time of task execution
|
||||||
* account_number: Specify the account number of an environment variable to be executed when the task is executed
|
- account_number: Specify the account number of an environment variable to be executed when the task is executed
|
||||||
* max_time: Timeout, suffix "s" for seconds (default), "m" for minutes, "h" for hours, "d" for days
|
- max_time: Timeout, suffix "s" for seconds (default), "m" for minutes, "h" for hours, "d" for days
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
@ -184,7 +191,7 @@ $ pnpm install
|
||||||
$ pnpm start
|
$ pnpm start
|
||||||
```
|
```
|
||||||
|
|
||||||
Open your browser and visit http://127.0.0.1:5700
|
Open your browser and visit <http://127.0.0.1:5700>
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
|
|
62
README.md
62
README.md
|
@ -120,9 +120,28 @@ export QL_DATA_DIR=""
|
||||||
qinglong
|
qinglong
|
||||||
```
|
```
|
||||||
|
|
||||||
## 使用
|
## 内置命令
|
||||||
|
|
||||||
1. 内置命令
|
1. task
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 依次执行,如果设置了随机延迟,将随机延迟一定秒数
|
||||||
|
task <file_path>
|
||||||
|
# 依次执行,无论是否设置了随机延迟,均立即运行,前台会输出日,同时记录在日志文件中
|
||||||
|
task <file_path> now
|
||||||
|
# 并发执行,无论是否设置了随机延迟,均立即运行,前台不产生日,直接记录在日志文件中,且可指定账号执行
|
||||||
|
task <file_path> conc <env_name> <account_number>(可选的)
|
||||||
|
# 指定账号执行,无论是否设置了随机延迟,均立即运行
|
||||||
|
task <file_path> desi <env_name> <account_number>
|
||||||
|
# 设置任务超时时间
|
||||||
|
task -m <max_time> <file_path>
|
||||||
|
# 实时打印任务日志,创建定时任务时,不用携带此参数
|
||||||
|
task -l <file_path>
|
||||||
|
# 使用 -- 分割,-- 后面的参数会传给脚本,下面的例子,脚本就可接收到参数 -u whyour -p password
|
||||||
|
task <file_path> -- -u whyour -p password
|
||||||
|
```
|
||||||
|
|
||||||
|
1. ql
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 更新并重启青龙
|
# 更新并重启青龙
|
||||||
|
@ -143,35 +162,22 @@ ql check
|
||||||
ql resetlet
|
ql resetlet
|
||||||
# 禁用两步登录
|
# 禁用两步登录
|
||||||
ql resettfa
|
ql resettfa
|
||||||
|
|
||||||
# 依次执行,如果设置了随机延迟,将随机延迟一定秒数
|
|
||||||
task <file_path>
|
|
||||||
# 依次执行,无论是否设置了随机延迟,均立即运行,前台会输出日,同时记录在日志文件中
|
|
||||||
task <file_path> now
|
|
||||||
# 并发执行,无论是否设置了随机延迟,均立即运行,前台不产生日,直接记录在日志文件中,且可指定账号执行
|
|
||||||
task <file_path> conc <env_name> <account_number>(可选的)
|
|
||||||
# 指定账号执行,无论是否设置了随机延迟,均立即运行
|
|
||||||
task <file_path> desi <env_name> <account_number>
|
|
||||||
# 设置任务超时时间
|
|
||||||
task -m <max_time> <file_path>
|
|
||||||
# 实时打印任务日志,创建定时任务时,不用携带此参数
|
|
||||||
task -l <file_path>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
2. 参数说明
|
1. 参数说明
|
||||||
|
|
||||||
* file_url: 脚本地址
|
- file_url: 脚本地址
|
||||||
* repo_url: 仓库地址
|
- repo_url: 仓库地址
|
||||||
* whitelist: 拉取仓库时的白名单,即就是需要拉取的脚本的路径包含的字符串,多个竖线分割
|
- whitelist: 拉取仓库时的白名单,即就是需要拉取的脚本的路径包含的字符串,多个竖线分割
|
||||||
* blacklist: 拉取仓库时的黑名单,即就是需要拉取的脚本的路径不包含的字符串,多个竖线分割
|
- blacklist: 拉取仓库时的黑名单,即就是需要拉取的脚本的路径不包含的字符串,多个竖线分割
|
||||||
* dependence: 拉取仓库需要的依赖文件,会直接从仓库拷贝到scripts下的仓库目录,不受黑名单影响,多个竖线分割
|
- dependence: 拉取仓库需要的依赖文件,会直接从仓库拷贝到scripts下的仓库目录,不受黑名单影响,多个竖线分割
|
||||||
* extensions: 拉取仓库的文件后缀,多个竖线分割
|
- extensions: 拉取仓库的文件后缀,多个竖线分割
|
||||||
* branch: 拉取仓库的分支
|
- branch: 拉取仓库的分支
|
||||||
* days: 需要保留的日志的天数
|
- days: 需要保留的日志的天数
|
||||||
* file_path: 任务执行时的文件路径
|
- file_path: 任务执行时的文件路径
|
||||||
* env_name: 任务执行时需要并发或者指定时的环境变量名称
|
- env_name: 任务执行时需要并发或者指定时的环境变量名称
|
||||||
* account_number: 任务执行时指定某个环境变量需要执行的账号序号
|
- account_number: 任务执行时指定某个环境变量需要执行的账号序号
|
||||||
* max_time: 超时时间,后缀"s"代表秒(默认值), "m"代表分, "h"代表小时, "d"代表天
|
- max_time: 超时时间,后缀"s"代表秒(默认值), "m"代表分, "h"代表小时, "d"代表天
|
||||||
|
|
||||||
## 开发
|
## 开发
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ run_normal() {
|
||||||
file_param=${file_param/$relative_path\//}
|
file_param=${file_param/$relative_path\//}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$timeoutCmd $which_program $file_param
|
$timeoutCmd $which_program $file_param "${script_params[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
## 并发执行时,设定的 RandomDelay 不会生效,即所有任务立即执行
|
## 并发执行时,设定的 RandomDelay 不会生效,即所有任务立即执行
|
||||||
|
@ -147,7 +147,7 @@ run_concurrent() {
|
||||||
for i in "${!array[@]}"; do
|
for i in "${!array[@]}"; do
|
||||||
export "${env_param}=${array[i]}"
|
export "${env_param}=${array[i]}"
|
||||||
single_log_path="$dir_log/$log_dir/${single_log_time}_$((i + 1)).log"
|
single_log_path="$dir_log/$log_dir/${single_log_time}_$((i + 1)).log"
|
||||||
eval $timeoutCmd $which_program $file_param &>$single_log_path &
|
eval $timeoutCmd $which_program $file_param "${script_params[@]}" &>$single_log_path &
|
||||||
done
|
done
|
||||||
|
|
||||||
wait
|
wait
|
||||||
|
@ -190,7 +190,7 @@ run_designated() {
|
||||||
cd ${relative_path}
|
cd ${relative_path}
|
||||||
file_param=${file_param/$relative_path\//}
|
file_param=${file_param/$relative_path\//}
|
||||||
fi
|
fi
|
||||||
$timeoutCmd $which_program $file_param
|
$timeoutCmd $which_program $file_param "${script_params[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
## 运行其他命令
|
## 运行其他命令
|
||||||
|
@ -241,8 +241,8 @@ main() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_task_start "$@"
|
handle_task_start "${task_shell_params[@]}"
|
||||||
run_task_before "$@"
|
run_task_before "${task_shell_params[@]}"
|
||||||
main "$@"
|
main "${task_shell_params[@]}"
|
||||||
run_task_after "$@"
|
run_task_after "${task_shell_params[@]}"
|
||||||
handle_task_end "$@"
|
handle_task_end "${task_shell_params[@]}"
|
||||||
|
|
|
@ -95,6 +95,21 @@ format_params() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# params=$(echo "$@" | sed -E 's/([^ ])&([^ ])/\1\\\&\2/g')
|
# params=$(echo "$@" | sed -E 's/([^ ])&([^ ])/\1\\\&\2/g')
|
||||||
|
|
||||||
|
# 分割 task 内置参数和脚本参数
|
||||||
|
task_shell_params=()
|
||||||
|
script_params=()
|
||||||
|
found_double_dash=false
|
||||||
|
|
||||||
|
for arg in "$@"; do
|
||||||
|
if $found_double_dash; then
|
||||||
|
script_params+=("$arg")
|
||||||
|
elif [ "$arg" == "--" ]; then
|
||||||
|
found_double_dash=true
|
||||||
|
else
|
||||||
|
task_shell_params+=("$arg")
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
init_begin_time() {
|
init_begin_time() {
|
||||||
|
@ -119,8 +134,8 @@ if [[ $max_time ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
format_params "$@"
|
format_params "$@"
|
||||||
define_program "$@"
|
define_program "${task_shell_params[@]}"
|
||||||
handle_log_path "$@"
|
handle_log_path "${task_shell_params[@]}"
|
||||||
init_begin_time
|
init_begin_time
|
||||||
|
|
||||||
eval . $dir_shell/otask.sh "$cmd"
|
eval . $dir_shell/otask.sh "$cmd"
|
||||||
|
|
|
@ -461,5 +461,10 @@
|
||||||
"运行任务后执行的命令,比如 cp/mv/python3 xxx.py/node xxx.js": "Run commands after executing the task, e.g., cp/mv/python3 xxx.py/node xxx.js",
|
"运行任务后执行的命令,比如 cp/mv/python3 xxx.py/node xxx.js": "Run commands after executing the task, e.g., cp/mv/python3 xxx.py/node xxx.js",
|
||||||
"请输入运行任务前要执行的命令,不能包含 task 命令": "Please enter the command to run before executing the task, cannot contain task commands",
|
"请输入运行任务前要执行的命令,不能包含 task 命令": "Please enter the command to run before executing the task, cannot contain task commands",
|
||||||
"请输入运行任务后要执行的命令,不能包含 task 命令": "Please enter the command to run after executing the task, cannot contain task commands",
|
"请输入运行任务后要执行的命令,不能包含 task 命令": "Please enter the command to run after executing the task, cannot contain task commands",
|
||||||
"不能包含 task 命令": "Cannot contain task commands"
|
"不能包含 task 命令": "Cannot contain task commands",
|
||||||
|
"Chronocat Red 服务的连接地址 https://chronocat.vercel.app/install/docker/official/": "Connection address of the Chronocat Red service https://chronocat.vercel.app/install/docker/official/",
|
||||||
|
"个人:user_id=个人QQ 群则填入group_id=QQ群 多个用英文;隔开同时支持个人和群 如:user_id=xxx;group_id=xxxx;group_id=xxxxx": "Individuals: user_id=individual QQ Groups fill in group_id=QQ Groups more than one with English; separated by the same time to support individuals and groups such as: user_id=xxx;group_id=xxxx;group_id=xxxxx",
|
||||||
|
"docker安装在持久化config目录下的chronocat.yml文件可找到": "The docker installation can be found in the persistence config directory in the chronocat.yml file",
|
||||||
|
"请选择": "Please select",
|
||||||
|
"请输入": "Please input"
|
||||||
}
|
}
|
||||||
|
|
|
@ -461,5 +461,10 @@
|
||||||
"运行任务后执行的命令,比如 cp/mv/python3 xxx.py/node xxx.js": "运行任务后执行的命令,比如 cp/mv/python3 xxx.py/node xxx.js",
|
"运行任务后执行的命令,比如 cp/mv/python3 xxx.py/node xxx.js": "运行任务后执行的命令,比如 cp/mv/python3 xxx.py/node xxx.js",
|
||||||
"请输入运行任务前要执行的命令,不能包含 task 命令": "请输入运行任务前要执行的命令,不能包含 task 命令",
|
"请输入运行任务前要执行的命令,不能包含 task 命令": "请输入运行任务前要执行的命令,不能包含 task 命令",
|
||||||
"请输入运行任务后要执行的命令,不能包含 task 命令": "请输入运行任务后要执行的命令,不能包含 task 命令",
|
"请输入运行任务后要执行的命令,不能包含 task 命令": "请输入运行任务后要执行的命令,不能包含 task 命令",
|
||||||
"不能包含 task 命令": "不能包含 task 命令"
|
"不能包含 task 命令": "不能包含 task 命令",
|
||||||
|
"Chronocat Red 服务的连接地址 https://chronocat.vercel.app/install/docker/official/": "Chronocat Red 服务的连接地址 https://chronocat.vercel.app/install/docker/official/",
|
||||||
|
"个人:user_id=个人QQ 群则填入group_id=QQ群 多个用英文;隔开同时支持个人和群 如:user_id=xxx;group_id=xxxx;group_id=xxxxx": "个人:user_id=个人QQ 群则填入group_id=QQ群 多个用英文;隔开同时支持个人和群 如:user_id=xxx;group_id=xxxx;group_id=xxxxx",
|
||||||
|
"docker安装在持久化config目录下的chronocat.yml文件可找到": "docker安装在持久化config目录下的chronocat.yml文件可找到",
|
||||||
|
"请选择": "请选择",
|
||||||
|
"请输入": "请输入"
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ const NotificationSetting = ({ data }: any) => {
|
||||||
>
|
>
|
||||||
{x.items ? (
|
{x.items ? (
|
||||||
<Select
|
<Select
|
||||||
placeholder={x.placeholder || `请选择${x.label}`}
|
placeholder={x.placeholder || `${intl.get('请选择')} ${x.label}`}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
>
|
>
|
||||||
{x.items.map((y) => (
|
{x.items.map((y) => (
|
||||||
|
@ -89,7 +89,7 @@ const NotificationSetting = ({ data }: any) => {
|
||||||
<Input.TextArea
|
<Input.TextArea
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
autoSize={{ minRows: 1, maxRows: 5 }}
|
autoSize={{ minRows: 1, maxRows: 5 }}
|
||||||
placeholder={x.placeholder || `请输入${x.label}`}
|
placeholder={x.placeholder || `${intl.get('请输入')} ${x.label}`}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user