mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-24 07:16:08 +08:00
修改任务最大内存占用200兆
This commit is contained in:
parent
0d23f8a962
commit
1413999ac3
|
@ -16,6 +16,8 @@ export default class ScheduleService {
|
||||||
|
|
||||||
private intervalSchedule = new ToadScheduler();
|
private intervalSchedule = new ToadScheduler();
|
||||||
|
|
||||||
|
private maxBuffer = 200 * 1024 * 1024;
|
||||||
|
|
||||||
constructor(@Inject('logger') private logger: winston.Logger) {}
|
constructor(@Inject('logger') private logger: winston.Logger) {}
|
||||||
|
|
||||||
async createCronTask({ id = 0, command, name, schedule = '' }: Crontab) {
|
async createCronTask({ id = 0, command, name, schedule = '' }: Crontab) {
|
||||||
|
@ -32,25 +34,29 @@ export default class ScheduleService {
|
||||||
_id,
|
_id,
|
||||||
nodeSchedule.scheduleJob(id + '', schedule, async () => {
|
nodeSchedule.scheduleJob(id + '', schedule, async () => {
|
||||||
try {
|
try {
|
||||||
exec(command, async (error, stdout, stderr) => {
|
exec(
|
||||||
if (error) {
|
command,
|
||||||
await this.logger.info(
|
{ maxBuffer: this.maxBuffer },
|
||||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
async (error, stdout, stderr) => {
|
||||||
command,
|
if (error) {
|
||||||
new Date().toLocaleString(),
|
await this.logger.info(
|
||||||
error,
|
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||||
);
|
command,
|
||||||
}
|
new Date().toLocaleString(),
|
||||||
|
error,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
await this.logger.info(
|
await this.logger.info(
|
||||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||||
command,
|
command,
|
||||||
new Date().toLocaleString(),
|
new Date().toLocaleString(),
|
||||||
stderr,
|
stderr,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await this.logger.info(
|
await this.logger.info(
|
||||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||||
|
@ -83,25 +89,29 @@ export default class ScheduleService {
|
||||||
);
|
);
|
||||||
const task = new Task(name, async () => {
|
const task = new Task(name, async () => {
|
||||||
try {
|
try {
|
||||||
exec(command, async (error, stdout, stderr) => {
|
exec(
|
||||||
if (error) {
|
command,
|
||||||
await this.logger.info(
|
{ maxBuffer: this.maxBuffer },
|
||||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
async (error, stdout, stderr) => {
|
||||||
command,
|
if (error) {
|
||||||
new Date().toLocaleString(),
|
await this.logger.info(
|
||||||
error,
|
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||||
);
|
command,
|
||||||
}
|
new Date().toLocaleString(),
|
||||||
|
error,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
await this.logger.info(
|
await this.logger.info(
|
||||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||||
command,
|
command,
|
||||||
new Date().toLocaleString(),
|
new Date().toLocaleString(),
|
||||||
stderr,
|
stderr,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await this.logger.info(
|
await this.logger.info(
|
||||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user