mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
修复依赖安装流程
This commit is contained in:
+11
-4
@@ -1,10 +1,17 @@
|
||||
import pLimit from "p-limit";
|
||||
import os from 'os';
|
||||
|
||||
const cronLimit = pLimit(os.cpus().length);
|
||||
const cpuLimit = pLimit(os.cpus().length);
|
||||
const oneLimit = pLimit(1);
|
||||
|
||||
export function runCronWithLimit<T>(fn: () => Promise<T>): Promise<T> {
|
||||
return cronLimit(() => {
|
||||
export function runWithCpuLimit<T>(fn: () => Promise<T>): Promise<T> {
|
||||
return cpuLimit(() => {
|
||||
return fn();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function runOneByOne<T>(fn: () => Promise<T>): Promise<T> {
|
||||
return oneLimit(() => {
|
||||
return fn();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { spawn } from 'cross-spawn';
|
||||
import { runCronWithLimit } from "./pLimit";
|
||||
import { runWithCpuLimit } from "./pLimit";
|
||||
import Logger from '../loaders/logger';
|
||||
|
||||
export function runCron(cmd: string): Promise<number> {
|
||||
return runCronWithLimit(() => {
|
||||
return runWithCpuLimit(() => {
|
||||
return new Promise(async (resolve: any) => {
|
||||
Logger.silly('运行命令: ' + cmd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user