mirror of
https://github.com/whyour/qinglong.git
synced 2025-08-23 19:56:07 +08:00
修复初始化更新镜像源配置
This commit is contained in:
parent
3bcba11b33
commit
9c258ab113
14
.github/workflows/build_docker_image.yml
vendored
14
.github/workflows/build_docker_image.yml
vendored
|
@ -17,7 +17,7 @@ jobs:
|
||||||
to_gitlab:
|
to_gitlab:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: pixta-dev/repository-mirroring-action@v1
|
- uses: pixta-dev/repository-mirroring-action@v1
|
||||||
|
@ -28,7 +28,7 @@ jobs:
|
||||||
to_gitee:
|
to_gitee:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: pixta-dev/repository-mirroring-action@v1
|
- uses: pixta-dev/repository-mirroring-action@v1
|
||||||
|
@ -39,12 +39,12 @@ jobs:
|
||||||
build-static:
|
build-static:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v3
|
||||||
with:
|
with:
|
||||||
version: "8.3.1"
|
version: "8.3.1"
|
||||||
|
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v3
|
||||||
with:
|
with:
|
||||||
version: "8.3.1"
|
version: "8.3.1"
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
|
@ -182,7 +182,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v3
|
||||||
with:
|
with:
|
||||||
version: "8.3.1"
|
version: "8.3.1"
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
|
|
|
@ -18,21 +18,47 @@ export default async () => {
|
||||||
const dependenceService = Container.get(DependenceService);
|
const dependenceService = Container.get(DependenceService);
|
||||||
const systemService = Container.get(SystemService);
|
const systemService = Container.get(SystemService);
|
||||||
|
|
||||||
|
const installDependencies = () => {
|
||||||
|
// 初始化时安装所有处于安装中,安装成功,安装失败的依赖
|
||||||
|
DependenceModel.findAll({
|
||||||
|
where: {},
|
||||||
|
order: [
|
||||||
|
['type', 'DESC'],
|
||||||
|
['createdAt', 'DESC'],
|
||||||
|
],
|
||||||
|
raw: true,
|
||||||
|
}).then(async (docs) => {
|
||||||
|
await DependenceModel.update(
|
||||||
|
{ status: DependenceStatus.queued, log: [] },
|
||||||
|
{ where: { id: docs.map((x) => x.id!) } },
|
||||||
|
);
|
||||||
|
setTimeout(() => {
|
||||||
|
dependenceService.installDependenceOneByOne(docs);
|
||||||
|
}, 5000);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// 初始化更新 linux/python/nodejs 镜像源配置
|
// 初始化更新 linux/python/nodejs 镜像源配置
|
||||||
const systemConfig = await systemService.getSystemConfig();
|
const systemConfig = await systemService.getSystemConfig();
|
||||||
if (systemConfig.info?.pythonMirror) {
|
if (systemConfig.info?.pythonMirror) {
|
||||||
systemService.updatePythonMirror({
|
systemService.updatePythonMirror({
|
||||||
linuxMirror: systemConfig.info?.linuxMirror,
|
pythonMirror: systemConfig.info?.pythonMirror,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (systemConfig.info?.linuxMirror) {
|
if (systemConfig.info?.linuxMirror) {
|
||||||
systemService.updateLinuxMirror({
|
systemService.updateLinuxMirror(
|
||||||
|
{
|
||||||
linuxMirror: systemConfig.info?.linuxMirror,
|
linuxMirror: systemConfig.info?.linuxMirror,
|
||||||
});
|
},
|
||||||
|
undefined,
|
||||||
|
() => installDependencies(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
installDependencies();
|
||||||
}
|
}
|
||||||
if (systemConfig.info?.nodeMirror) {
|
if (systemConfig.info?.nodeMirror) {
|
||||||
systemService.updateNodeMirror({
|
systemService.updateNodeMirror({
|
||||||
linuxMirror: systemConfig.info?.linuxMirror,
|
nodeMirror: systemConfig.info?.nodeMirror,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,24 +79,6 @@ export default async () => {
|
||||||
// 初始化更新所有任务状态为空闲
|
// 初始化更新所有任务状态为空闲
|
||||||
await CrontabModel.update({ status: CrontabStatus.idle }, { where: {} });
|
await CrontabModel.update({ status: CrontabStatus.idle }, { where: {} });
|
||||||
|
|
||||||
// 初始化时安装所有处于安装中,安装成功,安装失败的依赖
|
|
||||||
DependenceModel.findAll({
|
|
||||||
where: {},
|
|
||||||
order: [
|
|
||||||
['type', 'DESC'],
|
|
||||||
['createdAt', 'DESC'],
|
|
||||||
],
|
|
||||||
raw: true,
|
|
||||||
}).then(async (docs) => {
|
|
||||||
await DependenceModel.update(
|
|
||||||
{ status: DependenceStatus.queued, log: [] },
|
|
||||||
{ where: { id: docs.map((x) => x.id!) } },
|
|
||||||
);
|
|
||||||
setTimeout(() => {
|
|
||||||
dependenceService.installDependenceOneByOne(docs);
|
|
||||||
}, 5000);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 初始化时执行一次所有的 ql repo 任务
|
// 初始化时执行一次所有的 ql repo 任务
|
||||||
CrontabModel.findAll({
|
CrontabModel.findAll({
|
||||||
where: {
|
where: {
|
||||||
|
|
|
@ -177,7 +177,11 @@ export default class SystemService {
|
||||||
return { code: 200, data: info };
|
return { code: 200, data: info };
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateLinuxMirror(info: SystemModelInfo, res?: Response) {
|
public async updateLinuxMirror(
|
||||||
|
info: SystemModelInfo,
|
||||||
|
res?: Response,
|
||||||
|
onEnd?: () => void,
|
||||||
|
) {
|
||||||
const oDoc = await this.getSystemConfig();
|
const oDoc = await this.getSystemConfig();
|
||||||
await this.updateAuthDb({
|
await this.updateAuthDb({
|
||||||
...oDoc,
|
...oDoc,
|
||||||
|
@ -185,8 +189,12 @@ export default class SystemService {
|
||||||
});
|
});
|
||||||
let defaultDomain = 'https://dl-cdn.alpinelinux.org';
|
let defaultDomain = 'https://dl-cdn.alpinelinux.org';
|
||||||
let targetDomain = 'https://dl-cdn.alpinelinux.org';
|
let targetDomain = 'https://dl-cdn.alpinelinux.org';
|
||||||
if (oDoc.info?.linuxMirror) {
|
const content = await fs.promises.readFile('/etc/apk/repositories', {
|
||||||
defaultDomain = oDoc.info.linuxMirror;
|
encoding: 'utf-8',
|
||||||
|
});
|
||||||
|
const domainMatch = content.match(/(http.*)\/alpine\/.*/);
|
||||||
|
if (domainMatch) {
|
||||||
|
defaultDomain = domainMatch[1];
|
||||||
}
|
}
|
||||||
if (info.linuxMirror) {
|
if (info.linuxMirror) {
|
||||||
targetDomain = info.linuxMirror;
|
targetDomain = info.linuxMirror;
|
||||||
|
@ -211,6 +219,7 @@ export default class SystemService {
|
||||||
type: 'updateLinuxMirror',
|
type: 'updateLinuxMirror',
|
||||||
message: 'update linux mirror end',
|
message: 'update linux mirror end',
|
||||||
});
|
});
|
||||||
|
onEnd?.();
|
||||||
},
|
},
|
||||||
onError: async (message: string) => {
|
onError: async (message: string) => {
|
||||||
this.sockService.sendMessage({ type: 'updateLinuxMirror', message });
|
this.sockService.sendMessage({ type: 'updateLinuxMirror', message });
|
||||||
|
|
Loading…
Reference in New Issue
Block a user