mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
修复服务启动时定时删除日志失效
This commit is contained in:
parent
3aa112e373
commit
b0f3b51736
|
@ -44,7 +44,7 @@ export interface LoginLogInfo {
|
||||||
|
|
||||||
export type AuthModelInfo = SystemConfigInfo & Partial<NotificationInfo> & LoginLogInfo;
|
export type AuthModelInfo = SystemConfigInfo & Partial<NotificationInfo> & LoginLogInfo;
|
||||||
|
|
||||||
interface AuthInstance extends Model<AuthInfo, AuthInfo>, AuthInfo { }
|
export interface AuthInstance extends Model<AuthInfo, AuthInfo>, AuthInfo { }
|
||||||
export const AuthModel = sequelize.define<AuthInstance>('Auth', {
|
export const AuthModel = sequelize.define<AuthInstance>('Auth', {
|
||||||
ip: DataTypes.STRING,
|
ip: DataTypes.STRING,
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
|
|
|
@ -49,7 +49,7 @@ export enum CrontabStatus {
|
||||||
'disabled',
|
'disabled',
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CronInstance extends Model<Crontab, Crontab>, Crontab {}
|
export interface CronInstance extends Model<Crontab, Crontab>, Crontab {}
|
||||||
export const CrontabModel = sequelize.define<CronInstance>('Crontab', {
|
export const CrontabModel = sequelize.define<CronInstance>('Crontab', {
|
||||||
name: {
|
name: {
|
||||||
unique: 'compositeIndex',
|
unique: 'compositeIndex',
|
||||||
|
|
|
@ -39,7 +39,7 @@ export class CrontabView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CronViewInstance
|
export interface CronViewInstance
|
||||||
extends Model<CrontabView, CrontabView>,
|
extends Model<CrontabView, CrontabView>,
|
||||||
CrontabView {}
|
CrontabView {}
|
||||||
export const CrontabViewModel = sequelize.define<CronViewInstance>(
|
export const CrontabViewModel = sequelize.define<CronViewInstance>(
|
||||||
|
|
|
@ -52,7 +52,7 @@ export enum unInstallDependenceCommandTypes {
|
||||||
'apk del',
|
'apk del',
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DependenceInstance
|
export interface DependenceInstance
|
||||||
extends Model<Dependence, Dependence>,
|
extends Model<Dependence, Dependence>,
|
||||||
Dependence {}
|
Dependence {}
|
||||||
export const DependenceModel = sequelize.define<DependenceInstance>(
|
export const DependenceModel = sequelize.define<DependenceInstance>(
|
||||||
|
|
|
@ -34,7 +34,7 @@ export const initPosition = 4500000000000000;
|
||||||
export const stepPosition = 10000000000;
|
export const stepPosition = 10000000000;
|
||||||
export const minPosition = 100;
|
export const minPosition = 100;
|
||||||
|
|
||||||
interface EnvInstance extends Model<Env, Env>, Env {}
|
export interface EnvInstance extends Model<Env, Env>, Env {}
|
||||||
export const EnvModel = sequelize.define<EnvInstance>('Env', {
|
export const EnvModel = sequelize.define<EnvInstance>('Env', {
|
||||||
value: { type: DataTypes.STRING, unique: 'compositeIndex' },
|
value: { type: DataTypes.STRING, unique: 'compositeIndex' },
|
||||||
timestamp: DataTypes.STRING,
|
timestamp: DataTypes.STRING,
|
||||||
|
|
|
@ -26,7 +26,7 @@ export interface AppToken {
|
||||||
|
|
||||||
export type AppScope = 'envs' | 'crons' | 'configs' | 'scripts' | 'logs';
|
export type AppScope = 'envs' | 'crons' | 'configs' | 'scripts' | 'logs';
|
||||||
|
|
||||||
interface AppInstance extends Model<App, App>, App {}
|
export interface AppInstance extends Model<App, App>, App {}
|
||||||
export const AppModel = sequelize.define<AppInstance>('App', {
|
export const AppModel = sequelize.define<AppInstance>('App', {
|
||||||
name: { type: DataTypes.STRING, unique: 'name' },
|
name: { type: DataTypes.STRING, unique: 'name' },
|
||||||
scopes: DataTypes.JSON,
|
scopes: DataTypes.JSON,
|
||||||
|
|
|
@ -70,7 +70,7 @@ export enum SubscriptionStatus {
|
||||||
'queued',
|
'queued',
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SubscriptionInstance
|
export interface SubscriptionInstance
|
||||||
extends Model<Subscription, Subscription>,
|
extends Model<Subscription, Subscription>,
|
||||||
Subscription {}
|
Subscription {}
|
||||||
export const SubscriptionModel = sequelize.define<SubscriptionInstance>(
|
export const SubscriptionModel = sequelize.define<SubscriptionInstance>(
|
||||||
|
|
|
@ -30,15 +30,15 @@ export default async () => {
|
||||||
|
|
||||||
// 运行删除日志任务
|
// 运行删除日志任务
|
||||||
const data = await systemService.getSystemConfig();
|
const data = await systemService.getSystemConfig();
|
||||||
if (data && data.info && data.info.frequency) {
|
if (data && data.info && data.info.logRemoveFrequency) {
|
||||||
const rmlogCron = {
|
const rmlogCron = {
|
||||||
id: data.id,
|
id: data.id as number,
|
||||||
name: '删除日志',
|
name: '删除日志',
|
||||||
command: `ql rmlog ${data.info.frequency}`,
|
command: `ql rmlog ${data.info.logRemoveFrequency}`,
|
||||||
};
|
};
|
||||||
await scheduleService.cancelIntervalTask(rmlogCron);
|
await scheduleService.cancelIntervalTask(rmlogCron);
|
||||||
scheduleService.createIntervalTask(rmlogCron, {
|
scheduleService.createIntervalTask(rmlogCron, {
|
||||||
days: data.info.frequency,
|
days: data.info.logRemoveFrequency,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Service, Inject } from 'typedi';
|
||||||
import winston from 'winston';
|
import winston from 'winston';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import { AuthDataType, AuthInfo, AuthModel, AuthModelInfo } from '../data/auth';
|
import { AuthDataType, AuthInfo, AuthInstance, AuthModel, AuthModelInfo } from '../data/auth';
|
||||||
import { NotificationInfo } from '../data/notify';
|
import { NotificationInfo } from '../data/notify';
|
||||||
import NotificationService from './notify';
|
import NotificationService from './notify';
|
||||||
import ScheduleService, { TaskCallbacks } from './schedule';
|
import ScheduleService, { TaskCallbacks } from './schedule';
|
||||||
|
@ -34,15 +34,15 @@ export default class SystemService {
|
||||||
return doc || {};
|
return doc || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateAuthDb(payload: AuthInfo): Promise<any> {
|
private async updateAuthDb(payload: AuthInfo): Promise<AuthInstance> {
|
||||||
await AuthModel.upsert({ ...payload });
|
await AuthModel.upsert({ ...payload });
|
||||||
const doc = await this.getDb({ type: payload.type });
|
const doc = await this.getDb({ type: payload.type });
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getDb(query: any): Promise<any> {
|
public async getDb(query: any): Promise<AuthInstance> {
|
||||||
const doc: any = await AuthModel.findOne({ where: { ...query } });
|
const doc: any = await AuthModel.findOne({ where: { ...query } });
|
||||||
return doc && (doc.get({ plain: true }) as any);
|
return doc && (doc.get({ plain: true }));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateNotificationMode(notificationInfo: NotificationInfo) {
|
public async updateNotificationMode(notificationInfo: NotificationInfo) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user