mirror of
				https://github.com/whyour/qinglong.git
				synced 2025-10-31 17:06:07 +08:00 
			
		
		
		
	修复任务跳转脚本参数,task运行脚本支持更多参数
This commit is contained in:
		
							parent
							
								
									a9be3e6376
								
							
						
					
					
						commit
						931f02ef8e
					
				
							
								
								
									
										13
									
								
								cli/commands/update.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								cli/commands/update.ts
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | ||||||
|  | import { CommandModule } from 'yargs'; | ||||||
|  | export const updateCommand: CommandModule = { | ||||||
|  |   command: 'update', | ||||||
|  |   describe: 'Update and restart qinglong', | ||||||
|  |   builder: (yargs) => { | ||||||
|  |     return yargs.option('repositority', { | ||||||
|  |       type: 'string', | ||||||
|  |       alias: 'r', | ||||||
|  |       describe: `Specify the release warehouse address of the package`, | ||||||
|  |     }); | ||||||
|  |   }, | ||||||
|  |   handler: async (argv) => {}, | ||||||
|  | }; | ||||||
							
								
								
									
										12
									
								
								cli/index.ts
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								cli/index.ts
									
									
									
									
									
								
							|  | @ -1,3 +1,13 @@ | ||||||
| import * as yargs from 'yargs'; | import * as yargs from 'yargs'; | ||||||
|  | import { green, red } from 'chalk'; | ||||||
|  | import { updateCommand } from './commands/update'; | ||||||
| 
 | 
 | ||||||
| yargs.help('h').alias('h', 'help').help().argv; | yargs | ||||||
|  |   .usage('Usage: ql [command] <options>') | ||||||
|  |   .command(updateCommand) | ||||||
|  |   .fail((err) => { | ||||||
|  |     console.error(`${red(err)}`); | ||||||
|  |   }) | ||||||
|  |   .alias('h', 'help') | ||||||
|  |   .showHelp() | ||||||
|  |   .recommendCommands().argv; | ||||||
|  |  | ||||||
|  | @ -264,13 +264,18 @@ run_designated() { | ||||||
| 
 | 
 | ||||||
| ## 运行其他命令 | ## 运行其他命令 | ||||||
| run_else() { | run_else() { | ||||||
|     local log_time=$(date "+%Y-%m-%d-%H-%M-%S") |     local file_param="$1" | ||||||
|     local log_dir_tmp="${1##*/}" |     define_program "$file_param" | ||||||
|     local log_dir="$dir_log/${log_dir_tmp%%.*}" |     log_time=$(date "+%Y-%m-%d-%H-%M-%S") | ||||||
|  |     log_dir_tmp="${file_param##*/}" | ||||||
|  |     log_dir_tmp_path="${file_param%%/*}" | ||||||
|  |     log_dir_tmp_path="${log_dir_tmp_path##*/}" | ||||||
|  |     [[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}" | ||||||
|  |     log_dir="$dir_log/${log_dir_tmp%%.*}" | ||||||
|     log_path="$log_dir/$log_time.log" |     log_path="$log_dir/$log_time.log" | ||||||
|     cmd="&>> $log_path" |     cmd="&>> $log_path" | ||||||
|     [[ "$show_log" == "true" ]] && cmd="" |     [[ "$show_log" == "true" ]] && cmd="" | ||||||
|     make_dir "$log_dir" |     make_dir $log_dir | ||||||
| 
 | 
 | ||||||
|     local begin_time=$(date '+%Y-%m-%d %H:%M:%S') |     local begin_time=$(date '+%Y-%m-%d %H:%M:%S') | ||||||
|     local begin_timestamp=$(date "+%s" -d "$begin_time") |     local begin_timestamp=$(date "+%s" -d "$begin_time") | ||||||
|  | @ -278,13 +283,21 @@ run_else() { | ||||||
|     eval echo -e "\#\# 开始执行... $begin_time\\\n" $cmd |     eval echo -e "\#\# 开始执行... $begin_time\\\n" $cmd | ||||||
|     [[ -f $task_error_log_path ]] && eval cat $task_error_log_path $cmd |     [[ -f $task_error_log_path ]] && eval cat $task_error_log_path $cmd | ||||||
| 
 | 
 | ||||||
|     local id=$(cat $list_crontab_user | grep -E "$cmd_task $first_param" | perl -pe "s|.*ID=(.*) $cmd_task $first_param\.*|\1|" | head -1 | awk -F " " '{print $1}') |     local id=$(cat $list_crontab_user | grep -E "$cmd_task $@" | perl -pe "s|.*ID=(.*) $cmd_task $@\.*|\1|" | head -1 | awk -F " " '{print $1}') | ||||||
|     [[ $id ]] && update_cron "\"$id\"" "0" "$$" "$log_path" "$begin_timestamp" |     [[ $id ]] && update_cron "\"$id\"" "0" "$$" "$log_path" "$begin_timestamp" | ||||||
|     eval . $file_task_before "$@" $cmd |     eval . $file_task_before "$@" $cmd | ||||||
| 
 | 
 | ||||||
|     eval timeout -k 10s $command_timeout_time "$@" $cmd |     cd $dir_scripts | ||||||
|  |     local relative_path="${file_param%/*}" | ||||||
|  |     if [[ ! -z ${relative_path} ]] && [[ ${file_param} =~ "/" ]]; then | ||||||
|  |         cd ${relative_path} | ||||||
|  |         file_param=${file_param/$relative_path\//} | ||||||
|  |     fi | ||||||
| 
 | 
 | ||||||
|     eval . $file_task_after "$@" $cmd |     shift | ||||||
|  |     eval timeout -k 10s $command_timeout_time $which_program "$file_param" "$@" $cmd | ||||||
|  | 
 | ||||||
|  |     eval . $file_task_after "$file_param" "$@" $cmd | ||||||
|     local end_time=$(date '+%Y-%m-%d %H:%M:%S') |     local end_time=$(date '+%Y-%m-%d %H:%M:%S') | ||||||
|     local end_timestamp=$(date "+%s" -d "$end_time") |     local end_timestamp=$(date "+%s" -d "$end_time") | ||||||
|     local diff_time=$(( $end_timestamp - $begin_timestamp )) |     local diff_time=$(( $end_timestamp - $begin_timestamp )) | ||||||
|  |  | ||||||
|  | @ -335,8 +335,12 @@ const Crontab = ({ headerStyle, isPhone }: any) => { | ||||||
|   const [tableScrollHeight, setTableScrollHeight] = useState<number>(); |   const [tableScrollHeight, setTableScrollHeight] = useState<number>(); | ||||||
| 
 | 
 | ||||||
|   const goToScriptManager = (record: any) => { |   const goToScriptManager = (record: any) => { | ||||||
|     const cmd = record.command.split(' '); |     const cmd = record.command.split(' ') as string[]; | ||||||
|     if (cmd[0] === 'task') { |     if (cmd[0] === 'task') { | ||||||
|  |       if (cmd[1].startsWith('/ql/scripts')) { | ||||||
|  |         cmd[1] = cmd[1].replace('/ql/scripts/', ''); | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|       let [p, s] = cmd[1].split('/'); |       let [p, s] = cmd[1].split('/'); | ||||||
|       if (!s) { |       if (!s) { | ||||||
|         s = p; |         s = p; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 whyour
						whyour