mirror of
https://github.com/whyour/qinglong.git
synced 2026-06-30 20:35:09 +08:00
session api改为批量操作
This commit is contained in:
+15
-11
@@ -191,9 +191,13 @@ export default class CookieService {
|
||||
});
|
||||
}
|
||||
|
||||
public async remove(_id: string) {
|
||||
this.cronDb.remove({ _id }, {});
|
||||
await this.set_cookies();
|
||||
public async remove(ids: string[]) {
|
||||
return new Promise((resolve: any) => {
|
||||
this.cronDb.remove({ _id: { $in: ids } }, {}, async (err) => {
|
||||
await this.set_cookies();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public async move(
|
||||
@@ -283,29 +287,29 @@ export default class CookieService {
|
||||
});
|
||||
}
|
||||
|
||||
public async disabled(_id: string) {
|
||||
return new Promise((resolve) => {
|
||||
public async disabled(ids: string) {
|
||||
return new Promise((resolve: any) => {
|
||||
this.cronDb.update(
|
||||
{ _id },
|
||||
{ _id: { $in: ids } },
|
||||
{ $set: { status: CookieStatus.disabled } },
|
||||
{},
|
||||
async (err) => {
|
||||
await this.set_cookies();
|
||||
resolve(true);
|
||||
resolve();
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public async enabled(_id: string) {
|
||||
return new Promise((resolve) => {
|
||||
public async enabled(ids: string) {
|
||||
return new Promise((resolve: any) => {
|
||||
this.cronDb.update(
|
||||
{ _id },
|
||||
{ _id: { $in: ids } },
|
||||
{ $set: { status: CookieStatus.noacquired } },
|
||||
{},
|
||||
async (err, num) => {
|
||||
await this.set_cookies();
|
||||
resolve(true);
|
||||
resolve();
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
+49
-26
@@ -88,8 +88,16 @@ export default class CronService {
|
||||
}
|
||||
|
||||
public async remove(ids: string[]) {
|
||||
this.cronDb.remove({ _id: { $in: ids } }, { multi: true });
|
||||
await this.set_crontab(true);
|
||||
return new Promise((resolve: any) => {
|
||||
this.cronDb.remove(
|
||||
{ _id: { $in: ids } },
|
||||
{ multi: true },
|
||||
async (err) => {
|
||||
await this.set_crontab(true);
|
||||
resolve();
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public async crontabs(searchText?: string): Promise<Crontab[]> {
|
||||
@@ -141,17 +149,21 @@ export default class CronService {
|
||||
}
|
||||
|
||||
public async stop(ids: string[]) {
|
||||
this.cronDb.find({ _id: { $in: ids } }).exec((err, docs: Crontab[]) => {
|
||||
this.cronDb.update(
|
||||
{ _id: { $in: ids } },
|
||||
{ $set: { status: CrontabStatus.idle }, $unset: { pid: true } },
|
||||
);
|
||||
const pids = docs
|
||||
.map((x) => x.pid)
|
||||
.filter((x) => !!x)
|
||||
.join('\n');
|
||||
console.log(pids);
|
||||
exec(`echo - e "${pids}" | xargs kill - 9`);
|
||||
return new Promise((resolve: any) => {
|
||||
this.cronDb.find({ _id: { $in: ids } }).exec((err, docs: Crontab[]) => {
|
||||
this.cronDb.update(
|
||||
{ _id: { $in: ids } },
|
||||
{ $set: { status: CrontabStatus.idle }, $unset: { pid: true } },
|
||||
);
|
||||
const pids = docs
|
||||
.map((x) => x.pid)
|
||||
.filter((x) => !!x)
|
||||
.join('\n');
|
||||
console.log(pids);
|
||||
exec(`echo - e "${pids}" | xargs kill - 9`, (err) => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -222,21 +234,31 @@ export default class CronService {
|
||||
}
|
||||
|
||||
public async disabled(ids: string[]) {
|
||||
this.cronDb.update(
|
||||
{ _id: { $in: ids } },
|
||||
{ $set: { isDisabled: 1 } },
|
||||
{ multi: true },
|
||||
);
|
||||
await this.set_crontab(true);
|
||||
return new Promise((resolve: any) => {
|
||||
this.cronDb.update(
|
||||
{ _id: { $in: ids } },
|
||||
{ $set: { isDisabled: 1 } },
|
||||
{ multi: true },
|
||||
async (err) => {
|
||||
await this.set_crontab(true);
|
||||
resolve();
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public async enabled(ids: string[]) {
|
||||
this.cronDb.update(
|
||||
{ _id: { $in: ids } },
|
||||
{ $set: { isDisabled: 0 } },
|
||||
{ multi: true },
|
||||
);
|
||||
await this.set_crontab(true);
|
||||
return new Promise((resolve: any) => {
|
||||
this.cronDb.update(
|
||||
{ _id: { $in: ids } },
|
||||
{ $set: { isDisabled: 0 } },
|
||||
{ multi: true },
|
||||
async (err) => {
|
||||
await this.set_crontab(true);
|
||||
resolve();
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public async log(_id: string) {
|
||||
@@ -289,7 +311,8 @@ export default class CronService {
|
||||
|
||||
lines.reverse().forEach((line, index) => {
|
||||
line = line.replace(/\t+/g, ' ');
|
||||
var regex = /^((\@[a-zA-Z]+\s+)|(([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+))/;
|
||||
var regex =
|
||||
/^((\@[a-zA-Z]+\s+)|(([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+))/;
|
||||
var command = line.replace(regex, '').trim();
|
||||
var schedule = line.replace(command, '').trim();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user