mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 14:56:07 +08:00
修复错误信息展示
This commit is contained in:
parent
f947866c32
commit
a9b9c4d7ad
|
@ -387,28 +387,22 @@ export function emptyDir(path: string) {
|
||||||
fs.rmdirSync(path);
|
fs.rmdirSync(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function promiseExec(command: string): Promise<string> {
|
export async function promiseExec(command: string): Promise<string> {
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
exec(
|
const { stderr, stdout } = await promisify(exec)(command, { maxBuffer: 200 * 1024 * 1024, encoding: 'utf8' });
|
||||||
command,
|
return stdout || stderr;
|
||||||
{ maxBuffer: 200 * 1024 * 1024, encoding: 'utf8' },
|
} catch (error) {
|
||||||
(err, stdout, stderr) => {
|
return JSON.stringify(error);
|
||||||
resolve(stdout || stderr || JSON.stringify(err));
|
}
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function promiseExecSuccess(command: string): Promise<string> {
|
export async function promiseExecSuccess(command: string): Promise<string> {
|
||||||
return new Promise((resolve) => {
|
try {
|
||||||
exec(
|
const { stdout } = await promisify(exec)(command, { maxBuffer: 200 * 1024 * 1024, encoding: 'utf8' });
|
||||||
command,
|
return stdout || '';
|
||||||
{ maxBuffer: 200 * 1024 * 1024, encoding: 'utf8' },
|
} catch (error) {
|
||||||
(err, stdout, stderr) => {
|
return '';
|
||||||
resolve(stdout || '');
|
}
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseHeaders(headers: string) {
|
export function parseHeaders(headers: string) {
|
||||||
|
@ -501,7 +495,7 @@ export async function killTask(pid: number) {
|
||||||
[pid, ...pids].forEach((x) => {
|
[pid, ...pids].forEach((x) => {
|
||||||
process.kill(x, 2);
|
process.kill(x, 2);
|
||||||
});
|
});
|
||||||
} catch (error) {}
|
} catch (error) { }
|
||||||
} else {
|
} else {
|
||||||
process.kill(pid, 2);
|
process.kill(pid, 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ async function linkCommand() {
|
||||||
if (fs.existsSync(target)) {
|
if (fs.existsSync(target)) {
|
||||||
fs.unlinkSync(target);
|
fs.unlinkSync(target);
|
||||||
}
|
}
|
||||||
fs.symlink(source, target, (err) => {});
|
fs.symlink(source, target, (err) => { });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ const check = async (
|
||||||
`tail -n 300 ~/.pm2/logs/schedule-error.log`,
|
`tail -n 300 ~/.pm2/logs/schedule-error.log`,
|
||||||
);
|
);
|
||||||
return callback(
|
return callback(
|
||||||
new Error(`${scheduleErrLog || ''}\n${panelErrLog || ''}\n${res}`),
|
new Error(`${scheduleErrLog || ''}\n${panelErrLog || ''}\n${res}`.trim()),
|
||||||
);
|
);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
10
src/app.ts
10
src/app.ts
|
@ -3,13 +3,17 @@ import intl from 'react-intl-universal';
|
||||||
|
|
||||||
export function rootContainer(container: any) {
|
export function rootContainer(container: any) {
|
||||||
const locales = {
|
const locales = {
|
||||||
'en-US': require('./locales/en-US.json'),
|
'en': require('./locales/en-US.json'),
|
||||||
'zh-CN': require('./locales/zh-CN.json'),
|
'zh': require('./locales/zh-CN.json'),
|
||||||
};
|
};
|
||||||
let currentLocale = intl.determineLocale({
|
let currentLocale = intl.determineLocale({
|
||||||
urlLocaleKey: 'lang',
|
urlLocaleKey: 'lang',
|
||||||
cookieLocaleKey: 'lang',
|
cookieLocaleKey: 'lang',
|
||||||
});
|
}).slice(0, 2);
|
||||||
|
|
||||||
|
if (!currentLocale || !Object.keys(locales).includes(currentLocale)) {
|
||||||
|
currentLocale = 'zh';
|
||||||
|
}
|
||||||
|
|
||||||
intl.init({ currentLocale, locales });
|
intl.init({ currentLocale, locales });
|
||||||
return container;
|
return container;
|
||||||
|
|
|
@ -47,7 +47,7 @@ const CronLogModal = ({
|
||||||
const log = data as string;
|
const log = data as string;
|
||||||
setValue(log || intl.get('暂无日志'));
|
setValue(log || intl.get('暂无日志'));
|
||||||
const hasNext = Boolean(
|
const hasNext = Boolean(
|
||||||
log && !logEnded(log) && !log.includes(intl.get('任务未运行')),
|
log && !logEnded(log) && !log.includes('任务未运行'),
|
||||||
);
|
);
|
||||||
setExecuting(hasNext);
|
setExecuting(hasNext);
|
||||||
autoScroll();
|
autoScroll();
|
||||||
|
|
|
@ -9,17 +9,22 @@ import { SharedContext } from '@/layouts';
|
||||||
import { Alert, Typography } from 'antd';
|
import { Alert, Typography } from 'antd';
|
||||||
|
|
||||||
const Error = () => {
|
const Error = () => {
|
||||||
const { user, theme, reloadUser } = useOutletContext<SharedContext>();
|
const { user } = useOutletContext<SharedContext>();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [data, setData] = useState(intl.get('暂无日志'));
|
const [data, setData] = useState(intl.get('暂无日志'));
|
||||||
const retryTimes = useRef(1);
|
const retryTimes = useRef(1);
|
||||||
|
|
||||||
const getLog = (needLoading: boolean = true) => {
|
const getHealthStatus = (needLoading: boolean = true) => {
|
||||||
needLoading && setLoading(true);
|
needLoading && setLoading(true);
|
||||||
request
|
request
|
||||||
.get(`${config.apiPrefix}public/health`)
|
.get(`${config.apiPrefix}public/health`)
|
||||||
.then(({ error, data }) => {
|
.then(({ error, data }) => {
|
||||||
if (data?.status === 1) {
|
if (data?.status === 1) {
|
||||||
|
if (retryTimes.current > 1) {
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (retryTimes.current > 3) {
|
if (retryTimes.current > 3) {
|
||||||
|
@ -28,7 +33,7 @@ const Error = () => {
|
||||||
}
|
}
|
||||||
retryTimes.current += 1;
|
retryTimes.current += 1;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getLog(false);
|
getHealthStatus(false);
|
||||||
}, 3000);
|
}, 3000);
|
||||||
})
|
})
|
||||||
.finally(() => needLoading && setLoading(false));
|
.finally(() => needLoading && setLoading(false));
|
||||||
|
@ -41,7 +46,7 @@ const Error = () => {
|
||||||
}, [user]);
|
}, [user]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getLog();
|
getHealthStatus();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user