mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +08:00
修复定时任务获取日志目录
This commit is contained in:
parent
d0b13a04cc
commit
0d23f8a962
|
@ -353,6 +353,21 @@ export default class CronService {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (doc.log_path) {
|
||||||
|
const relativeDir = `${doc.log_path.replace(/\/[^\/]\..*/, '')}`;
|
||||||
|
const dir = `${config.logPath}${relativeDir}`;
|
||||||
|
if (existsSync(dir)) {
|
||||||
|
let files = await promises.readdir(dir);
|
||||||
|
return files
|
||||||
|
.map((x) => ({
|
||||||
|
filename: x,
|
||||||
|
directory: relativeDir,
|
||||||
|
time: fs.statSync(`${dir}/${x}`).mtime.getTime(),
|
||||||
|
}))
|
||||||
|
.sort((a, b) => b.time - a.time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const [, commandStr, url] = doc.command.split(/ +/);
|
const [, commandStr, url] = doc.command.split(/ +/);
|
||||||
let logPath = this.getKey(commandStr);
|
let logPath = this.getKey(commandStr);
|
||||||
const isQlCommand = doc.command.startsWith('ql ');
|
const isQlCommand = doc.command.startsWith('ql ');
|
||||||
|
|
|
@ -14,7 +14,11 @@ const uploadToken = putPolicy.uploadToken(mac);
|
||||||
const localFile = 'src/version.ts';
|
const localFile = 'src/version.ts';
|
||||||
const config = new qiniu.conf.Config({ zone: qiniu.zone.Zone_z1 });
|
const config = new qiniu.conf.Config({ zone: qiniu.zone.Zone_z1 });
|
||||||
const formUploader = new qiniu.form_up.FormUploader(config);
|
const formUploader = new qiniu.form_up.FormUploader(config);
|
||||||
const putExtra = new qiniu.form_up.PutExtra('', '', 'text/plain');
|
const putExtra = new qiniu.form_up.PutExtra(
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'text/plain; charset=utf-8',
|
||||||
|
);
|
||||||
const key = 'version.ts';
|
const key = 'version.ts';
|
||||||
// 文件上传
|
// 文件上传
|
||||||
formUploader.putFile(
|
formUploader.putFile(
|
||||||
|
|
|
@ -89,9 +89,9 @@ run_normal() {
|
||||||
log_dir_tmp_path="${first_param%%/*}"
|
log_dir_tmp_path="${first_param%%/*}"
|
||||||
log_dir_tmp_path="${log_dir_tmp_path##*/}"
|
log_dir_tmp_path="${log_dir_tmp_path##*/}"
|
||||||
[[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}"
|
[[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}"
|
||||||
log_dir="$dir_log/${log_dir_tmp%%.*}"
|
log_dir="${log_dir_tmp%%.*}"
|
||||||
log_path="$log_dir/$log_time.log"
|
log_path="$log_dir/$log_time.log"
|
||||||
cmd="&>> $log_path"
|
cmd="&>> $dir_log/$log_path"
|
||||||
[[ "$show_log" == "true" ]] && cmd=""
|
[[ "$show_log" == "true" ]] && cmd=""
|
||||||
make_dir "$log_dir"
|
make_dir "$log_dir"
|
||||||
|
|
||||||
|
@ -151,9 +151,9 @@ run_concurrent() {
|
||||||
log_dir_tmp_path="${first_param%%/*}"
|
log_dir_tmp_path="${first_param%%/*}"
|
||||||
log_dir_tmp_path="${log_dir_tmp_path##*/}"
|
log_dir_tmp_path="${log_dir_tmp_path##*/}"
|
||||||
[[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}"
|
[[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}"
|
||||||
log_dir="$dir_log/${log_dir_tmp%%.*}"
|
log_dir="${log_dir_tmp%%.*}"
|
||||||
log_path="$log_dir/$log_time.log"
|
log_path="$log_dir/$log_time.log"
|
||||||
cmd="&>> $log_path"
|
cmd="&>> $dir_log/$log_path"
|
||||||
[[ "$show_log" == "true" ]] && cmd=""
|
[[ "$show_log" == "true" ]] && cmd=""
|
||||||
make_dir $log_dir
|
make_dir $log_dir
|
||||||
|
|
||||||
|
@ -213,9 +213,9 @@ run_designated() {
|
||||||
log_dir_tmp_path="${file_param%%/*}"
|
log_dir_tmp_path="${file_param%%/*}"
|
||||||
log_dir_tmp_path="${log_dir_tmp_path##*/}"
|
log_dir_tmp_path="${log_dir_tmp_path##*/}"
|
||||||
[[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}"
|
[[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}"
|
||||||
log_dir="$dir_log/${log_dir_tmp%%.*}"
|
log_dir="${log_dir_tmp%%.*}"
|
||||||
log_path="$log_dir/$log_time.log"
|
log_path="$log_dir/$log_time.log"
|
||||||
cmd="&>> $log_path"
|
cmd="&>> $dir_log/$log_path"
|
||||||
[[ "$show_log" == "true" ]] && cmd=""
|
[[ "$show_log" == "true" ]] && cmd=""
|
||||||
make_dir $log_dir
|
make_dir $log_dir
|
||||||
|
|
||||||
|
@ -269,9 +269,9 @@ run_else() {
|
||||||
log_dir_tmp_path="${file_param%%/*}"
|
log_dir_tmp_path="${file_param%%/*}"
|
||||||
log_dir_tmp_path="${log_dir_tmp_path##*/}"
|
log_dir_tmp_path="${log_dir_tmp_path##*/}"
|
||||||
[[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}"
|
[[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}"
|
||||||
log_dir="$dir_log/${log_dir_tmp%%.*}"
|
log_dir="${log_dir_tmp%%.*}"
|
||||||
log_path="$log_dir/$log_time.log"
|
log_path="$log_dir/$log_time.log"
|
||||||
cmd="&>> $log_path"
|
cmd="&>> $dir_log/$log_path"
|
||||||
[[ "$show_log" == "true" ]] && cmd=""
|
[[ "$show_log" == "true" ]] && cmd=""
|
||||||
make_dir $log_dir
|
make_dir $log_dir
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user