修改初始化依赖安装逻辑

This commit is contained in:
whyour 2023-03-18 22:26:29 +08:00
parent 81e2bbb14c
commit 666545ff03
3 changed files with 13 additions and 12 deletions

View File

@ -4,8 +4,7 @@ import { Container } from 'typedi';
import { Crontab, CrontabModel, CrontabStatus } from '../data/cron';
import CronService from '../services/cron';
import EnvService from '../services/env';
import groupBy from 'lodash/groupBy';
import { DependenceModel } from '../data/dependence';
import { DependenceModel, DependenceStatus } from '../data/dependence';
import { Op } from 'sequelize';
import config from '../config';
import { CrontabViewModel, CronViewType } from '../data/cronView';
@ -42,16 +41,14 @@ export default async () => {
order: [['type', 'DESC']],
raw: true,
}).then(async (docs) => {
const groups = groupBy(docs, 'type');
const keys = Object.keys(groups).sort((a, b) => parseInt(b) - parseInt(a));
for (const key of keys) {
const group = groups[key];
const depIds = group.map((x) => x.id);
await dependenceService.reInstall(depIds as number[]);
}
await DependenceModel.update(
{ status: DependenceStatus.installing, log: [] },
{ where: { id: docs.map((x) => x.id!) } },
);
dependenceService.installDependenceOneByOne(docs);
});
// 初始化时执行一次所有的ql repo 任务
// 初始化时执行一次所有的 ql repo 任务
CrontabModel.findAll({
where: {
isDisabled: { [Op.ne]: 1 },

View File

@ -99,7 +99,7 @@ export default class DependenceService {
}
}
private installDependenceOneByOne(
public installDependenceOneByOne(
docs: Dependence[],
isInstall: boolean = true,
force: boolean = false,

View File

@ -61,7 +61,11 @@ handle_log_path() {
format_params() {
time_format="%Y-%m-%d %H:%M:%S"
mtime_format="%Y-%m-%d %H:%M:%S.%3N"
if [[ $is_macos -eq 1 ]]; then
mtime_format=$time_format
else
mtime_format="%Y-%m-%d %H:%M:%S.%3N"
fi
timeoutCmd=""
if type timeout &>/dev/null; then
timeoutCmd="timeout --foreground -s 14 -k 10s $command_timeout_time "