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,7 +34,10 @@ 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(
|
||||||
|
command,
|
||||||
|
{ maxBuffer: this.maxBuffer },
|
||||||
|
async (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
await this.logger.info(
|
await this.logger.info(
|
||||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||||
|
@ -50,7 +55,8 @@ export default class ScheduleService {
|
||||||
stderr,
|
stderr,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await this.logger.info(
|
await this.logger.info(
|
||||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||||
|
@ -83,7 +89,10 @@ 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(
|
||||||
|
command,
|
||||||
|
{ maxBuffer: this.maxBuffer },
|
||||||
|
async (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
await this.logger.info(
|
await this.logger.info(
|
||||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||||
|
@ -101,7 +110,8 @@ export default class ScheduleService {
|
||||||
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