From 7f3e60423bc5dd4a5f9edc4c94be7ff60b507e1d Mon Sep 17 00:00:00 2001 From: whyour Date: Wed, 24 Jan 2024 22:55:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=AF=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E9=85=8D=E7=BD=AE=E6=9C=AA=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/loaders/initData.ts | 24 +++++++++++++++++++++++- back/services/system.ts | 12 ++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/back/loaders/initData.ts b/back/loaders/initData.ts index db3032f0..59bdf357 100644 --- a/back/loaders/initData.ts +++ b/back/loaders/initData.ts @@ -10,11 +10,31 @@ import config from '../config'; import { CrontabViewModel, CronViewType } from '../data/cronView'; import { initPosition } from '../data/env'; import { AuthDataType, SystemModel } from '../data/system'; +import SystemService from '../services/system'; export default async () => { const cronService = Container.get(CronService); const envService = Container.get(EnvService); const dependenceService = Container.get(DependenceService); + const systemService = Container.get(SystemService); + + // 初始化更新 linux/python/nodejs 镜像源配置 + const systemConfig = await systemService.getSystemConfig(); + if (systemConfig.info?.pythonMirror) { + systemService.updatePythonMirror({ + linuxMirror: systemConfig.info?.linuxMirror, + }); + } + if (systemConfig.info?.linuxMirror) { + systemService.updateLinuxMirror({ + linuxMirror: systemConfig.info?.linuxMirror, + }); + } + if (systemConfig.info?.nodeMirror) { + systemService.updateNodeMirror({ + linuxMirror: systemConfig.info?.linuxMirror, + }); + } // 初始化新增默认全部任务视图 CrontabViewModel.findAll({ @@ -46,7 +66,9 @@ export default async () => { { status: DependenceStatus.queued, log: [] }, { where: { id: docs.map((x) => x.id!) } }, ); - dependenceService.installDependenceOneByOne(docs); + setTimeout(() => { + dependenceService.installDependenceOneByOne(docs); + }, 5000); }); // 初始化时执行一次所有的 ql repo 任务 diff --git a/back/services/system.ts b/back/services/system.ts index fbb3e433..09cf6ee0 100644 --- a/back/services/system.ts +++ b/back/services/system.ts @@ -126,7 +126,7 @@ export default class SystemService { return { code: 200, data: info }; } - public async updateNodeMirror(info: SystemModelInfo, res: Response) { + public async updateNodeMirror(info: SystemModelInfo, res?: Response) { const oDoc = await this.getSystemConfig(); await this.updateAuthDb({ ...oDoc, @@ -141,8 +141,8 @@ export default class SystemService { command, { onStart: async (cp) => { - res.setHeader('QL-Task-Pid', `${cp.pid}`); - res.end(); + res?.setHeader('QL-Task-Pid', `${cp.pid}`); + res?.end(); }, onEnd: async () => { this.sockService.sendMessage({ @@ -177,7 +177,7 @@ export default class SystemService { return { code: 200, data: info }; } - public async updateLinuxMirror(info: SystemModelInfo, res: Response) { + public async updateLinuxMirror(info: SystemModelInfo, res?: Response) { const oDoc = await this.getSystemConfig(); await this.updateAuthDb({ ...oDoc, @@ -203,8 +203,8 @@ export default class SystemService { command, { onStart: async (cp) => { - res.setHeader('QL-Task-Pid', `${cp.pid}`); - res.end(); + res?.setHeader('QL-Task-Pid', `${cp.pid}`); + res?.end(); }, onEnd: async () => { this.sockService.sendMessage({