mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
修改日志结束符判定
This commit is contained in:
parent
42c64c82d7
commit
4194f1964d
1
back/config/const.ts
Normal file
1
back/config/const.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export const LOG_END_SYMBOL = '\n ';
|
|
@ -11,6 +11,7 @@ import { promisify } from 'util';
|
|||
import { Op } from 'sequelize';
|
||||
import path from 'path';
|
||||
import dayjs from 'dayjs';
|
||||
import { LOG_END_SYMBOL } from '../config/const';
|
||||
|
||||
@Service()
|
||||
export default class CronService {
|
||||
|
@ -335,7 +336,7 @@ export default class CronService {
|
|||
`${absolutePath}`,
|
||||
`${str}\n## 执行结束... ${endTime.format(
|
||||
'YYYY-MM-DD HH:mm:ss',
|
||||
)}${diffTimeStr}`,
|
||||
)}${diffTimeStr}${LOG_END_SYMBOL}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import SockService from './sock';
|
|||
import CronService from './cron';
|
||||
import ScheduleService, { TaskCallbacks } from './schedule';
|
||||
import config from '../config';
|
||||
import { LOG_END_SYMBOL } from '../config/const';
|
||||
|
||||
@Service()
|
||||
export default class ScriptService {
|
||||
|
@ -55,7 +56,7 @@ export default class ScriptService {
|
|||
type: 'manuallyRunScript',
|
||||
message: `${str}\n## 执行结束... ${new Date()
|
||||
.toLocaleString('zh', { hour12: false })
|
||||
.replace(' 24:', ' 00:')} `,
|
||||
.replace(' 24:', ' 00:')}${LOG_END_SYMBOL}`,
|
||||
});
|
||||
|
||||
return { code: 200 };
|
||||
|
|
|
@ -29,6 +29,7 @@ import { SimpleIntervalSchedule } from 'toad-scheduler';
|
|||
import SockService from './sock';
|
||||
import SshKeyService from './sshKey';
|
||||
import dayjs from 'dayjs';
|
||||
import { LOG_END_SYMBOL } from '../config/const';
|
||||
|
||||
@Service()
|
||||
export default class SubscriptionService {
|
||||
|
@ -232,7 +233,7 @@ export default class SubscriptionService {
|
|||
absolutePath,
|
||||
`\n## 执行结束... ${endTime.format(
|
||||
'YYYY-MM-DD HH:mm:ss',
|
||||
)} 耗时 ${diff} 秒`,
|
||||
)} 耗时 ${diff} 秒${LOG_END_SYMBOL}`,
|
||||
);
|
||||
|
||||
await SubscriptionModel.update(
|
||||
|
@ -353,7 +354,7 @@ export default class SubscriptionService {
|
|||
|
||||
fs.appendFileSync(
|
||||
`${absolutePath}`,
|
||||
`${str}\n## 执行结束... ${dayjs().format('YYYY-MM-DD HH:mm:ss')} `,
|
||||
`${str}\n## 执行结束... ${dayjs().format('YYYY-MM-DD HH:mm:ss')}${LOG_END_SYMBOL}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -157,6 +157,7 @@ handle_task_after() {
|
|||
local diff_time=$(($end_timestamp - $begin_timestamp))
|
||||
[[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time"
|
||||
eval echo -e "\\\n\\\n\#\# 执行结束... $end_time 耗时 $diff_time 秒" $cmd
|
||||
eval echo -e "\\\n " $cmd
|
||||
}
|
||||
|
||||
## 正常运行单个脚本,$1:传入参数
|
||||
|
|
|
@ -464,8 +464,8 @@ main() {
|
|||
if [[ -n $p2 ]]; then
|
||||
update_repo "$p2" "$p3" "$p4" "$p5" "$p6" "$p7"
|
||||
else
|
||||
echo -e "命令输入错误...\n"
|
||||
usage
|
||||
eval echo -e "命令输入错误...\\\n"
|
||||
eval usage $cmd
|
||||
fi
|
||||
;;
|
||||
raw)
|
||||
|
@ -473,8 +473,8 @@ main() {
|
|||
if [[ -n $p2 ]]; then
|
||||
update_raw "$p2"
|
||||
else
|
||||
echo -e "命令输入错误...\n"
|
||||
usage
|
||||
eval echo -e "命令输入错误...\\\n"
|
||||
eval usage $cmd
|
||||
fi
|
||||
;;
|
||||
rmlog)
|
||||
|
@ -497,16 +497,17 @@ main() {
|
|||
echo "$auth_value" >$file_auth_user
|
||||
;;
|
||||
*)
|
||||
echo -e "命令输入错误...\n"
|
||||
usage
|
||||
eval echo -e "命令输入错误...\\\n" $cmd
|
||||
eval usage $cmd
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -f $file_path ]]; then
|
||||
cat $file_path
|
||||
local end_timestamp=$(date "+%s")
|
||||
local diff_time=$(($end_timestamp - $begin_timestamp))
|
||||
[[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time"
|
||||
eval echo -e "\\\n " $cmd
|
||||
cat $file_path
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import {
|
|||
CheckCircleOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { PageLoading } from '@ant-design/pro-layout';
|
||||
import { logEnded } from '@/utils';
|
||||
|
||||
enum CrontabStatus {
|
||||
'running',
|
||||
|
@ -49,9 +50,9 @@ const CronLogModal = ({
|
|||
const log = data as string;
|
||||
setValue(log || '暂无日志');
|
||||
setExecuting(
|
||||
log && !log.includes('执行结束') && !log.includes('重启面板'),
|
||||
log && !logEnded(log) && !log.includes('重启面板'),
|
||||
);
|
||||
if (log && !log.includes('执行结束') && !log.includes('重启面板')) {
|
||||
if (log && !logEnded(log) && !log.includes('重启面板')) {
|
||||
setTimeout(() => {
|
||||
getCronLog();
|
||||
}, 2000);
|
||||
|
|
|
@ -7,6 +7,7 @@ import Editor from '@monaco-editor/react';
|
|||
import SaveModal from './saveModal';
|
||||
import SettingModal from './setting';
|
||||
import { useTheme } from '@/utils/hooks';
|
||||
import { logEnded } from '@/utils';
|
||||
|
||||
const { Option } = Select;
|
||||
const LangMap: any = {
|
||||
|
@ -128,7 +129,7 @@ const EditModal = ({
|
|||
return;
|
||||
}
|
||||
|
||||
if (_message.includes('执行结束')) {
|
||||
if (logEnded(_message)) {
|
||||
setTimeout(() => {
|
||||
setIsRunning(false);
|
||||
}, 300);
|
||||
|
|
|
@ -7,6 +7,7 @@ import {
|
|||
CheckCircleOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { PageLoading } from '@ant-design/pro-layout';
|
||||
import { logEnded } from '@/utils';
|
||||
|
||||
const SubscriptionLogModal = ({
|
||||
subscription,
|
||||
|
@ -43,8 +44,8 @@ const SubscriptionLogModal = ({
|
|||
) {
|
||||
const log = data as string;
|
||||
setValue(log || '暂无日志');
|
||||
setExecuting(log && !log.includes('执行结束'));
|
||||
if (log && !log.includes('执行结束')) {
|
||||
setExecuting(log && !logEnded(log));
|
||||
if (log && !logEnded(log)) {
|
||||
setTimeout(() => {
|
||||
getCronLog();
|
||||
}, 2000);
|
||||
|
|
1
src/utils/const.ts
Normal file
1
src/utils/const.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export const LOG_END_SYMBOL = '\n ';
|
|
@ -1,3 +1,5 @@
|
|||
import { LOG_END_SYMBOL } from "./const";
|
||||
|
||||
export default function browserType() {
|
||||
// 权重:系统 + 系统版本 > 平台 > 内核 + 载体 + 内核版本 + 载体版本 > 外壳 + 外壳版本
|
||||
const ua = navigator.userAgent.toLowerCase();
|
||||
|
@ -273,3 +275,8 @@ export function depthFirstSearch<
|
|||
|
||||
return c;
|
||||
}
|
||||
|
||||
export function logEnded(log: string): boolean {
|
||||
const endTips = [LOG_END_SYMBOL, '执行结束'];
|
||||
return endTips.some(x => !log.includes(x));
|
||||
}
|
|
@ -7,6 +7,9 @@
|
|||
"./src/types",
|
||||
"./node_modules/celebrate/lib/index.d.ts"
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["back/*"],
|
||||
},
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
|
|
Loading…
Reference in New Issue
Block a user