增加初始化订阅任务

This commit is contained in:
whyour
2022-05-18 23:30:59 +08:00
parent d2c2ea8d3b
commit 460a1750f4
6 changed files with 24 additions and 7 deletions
+8
View File
@@ -2,10 +2,12 @@ import { Container } from 'typedi';
import _ from 'lodash';
import SystemService from '../services/system';
import ScheduleService from '../services/schedule';
import SubscriptionService from '../services/subscription';
export default async () => {
const systemService = Container.get(SystemService);
const scheduleService = Container.get(ScheduleService);
const subscriptionService = Container.get(SubscriptionService);
// 运行删除日志任务
const data = await systemService.getLogRemoveFrequency();
@@ -20,4 +22,10 @@ export default async () => {
runImmediately: true,
});
}
// 运行所有订阅
const subs = await subscriptionService.list();
for (const sub of subs) {
await subscriptionService.handleTask(sub);
}
};
+1 -1
View File
@@ -32,7 +32,7 @@ export default class SshKeyService {
}
private generateSingleSshConfig(alias: string, host: string): string {
return `\nHost ${alias}\n Hostname ${host}\n IdentityFile=${this.sshPath}/${alias}\n StrictHostKeyChecking no`;
return `\nHost ${alias}\n Hostname ${host}\n IdentityFile ${this.sshPath}/${alias}\n StrictHostKeyChecking no`;
}
private generateSshConfig(configs: string[]) {
+1 -1
View File
@@ -124,7 +124,7 @@ export default class SubscriptionService {
return { url, host };
}
private handleTask(doc: Subscription, needCreate = true, needAddKey = true) {
public handleTask(doc: Subscription, needCreate = true, needAddKey = true) {
const { url, host } = this.formatUrl(doc);
if (doc.type === 'private-repo' && doc.pull_type === 'ssh-key') {
if (needAddKey) {