初始化保存一次session和cron数据

This commit is contained in:
whyour 2021-05-14 10:20:41 +08:00
parent 6d44b0ef0c
commit 2ba99d9c47
2 changed files with 7 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import { exec } from 'child_process';
import { Container } from 'typedi';
import { Crontab, CrontabStatus } from '../data/cron';
import CronService from '../services/cron';
import CookieService from '../services/cookie';
const initData = [
{
@ -29,6 +30,7 @@ const initData = [
export default async () => {
const cronService = Container.get(CronService);
const cookieService = Container.get(CookieService);
const cronDb = cronService.getDb();
cronDb.count({}, async (err, count) => {
@ -71,6 +73,10 @@ export default async () => {
exec(doc.command);
}
});
// 初始化保存一次ck和定时任务数据
await cronService.autosave_crontab();
await cookieService.set_cookies();
};
function randomSchedule(from: number, to: number) {

View File

@ -292,7 +292,7 @@ export default class CookieService {
this.cronDb.update({ _id }, { $set: { status: CookieStatus.noacquired } });
}
private async set_cookies() {
public async set_cookies() {
const cookies = await this.cookies();
let cookie_string = '';
cookies.forEach((tab) => {