mirror of
https://github.com/whyour/qinglong.git
synced 2026-06-30 20:35:09 +08:00
增加初始化订阅任务
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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[]) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user