mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add logger for task
This commit is contained in:
1 parent
3af3453166
commit
b3aa0a5e09
5 files changed
+7
-3
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/hydrojudge",
|
"name": "@hydrooj/hydrojudge",
|
||||||
"bin": "bin/hydrojudge.js",
|
"bin": "bin/hydrojudge.js",
|
||||||
"version": "2.1.9",
|
"version": "2.1.10",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"author": "masnn",
|
"author": "masnn",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ async function readAutoCases(folder, { next }) {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function readYamlCases(folder: string, cfg: Dictionary<any>, args) {
|
export async function readYamlCases(folder: string, cfg: Dictionary<any> = {}, args) {
|
||||||
const config: any = {
|
const config: any = {
|
||||||
checker_type: 'default',
|
checker_type: 'default',
|
||||||
count: 0,
|
count: 0,
|
||||||
|
|||||||
@@ -187,6 +187,7 @@ async function postInit() {
|
|||||||
this.stat = {};
|
this.stat = {};
|
||||||
this.stat.receive = new Date();
|
this.stat.receive = new Date();
|
||||||
this.request = request;
|
this.request = request;
|
||||||
|
logger.debug('%o', request);
|
||||||
}
|
}
|
||||||
|
|
||||||
async handle() {
|
async handle() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.13.28",
|
"version": "2.13.29",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import moment from 'moment-timezone';
|
import moment from 'moment-timezone';
|
||||||
import { FilterQuery, ObjectID } from 'mongodb';
|
import { FilterQuery, ObjectID } from 'mongodb';
|
||||||
import { Task } from '../interface';
|
import { Task } from '../interface';
|
||||||
|
import { Logger } from '../logger';
|
||||||
import * as db from '../service/db';
|
import * as db from '../service/db';
|
||||||
|
|
||||||
|
const logger = new Logger('model/task');
|
||||||
const coll = db.collection('task');
|
const coll = db.collection('task');
|
||||||
|
|
||||||
export async function add(task: Partial<Task> & { type: string }) {
|
export async function add(task: Partial<Task> & { type: string }) {
|
||||||
@@ -34,6 +36,7 @@ export async function getFirst(query: FilterQuery<Task>) {
|
|||||||
q.executeAfter = q.executeAfter || { $lt: new Date() };
|
q.executeAfter = q.executeAfter || { $lt: new Date() };
|
||||||
const res = await coll.findOneAndDelete(q);
|
const res = await coll.findOneAndDelete(q);
|
||||||
if (res.value) {
|
if (res.value) {
|
||||||
|
logger.debug('%o', res.value);
|
||||||
if (res.value.interval) {
|
if (res.value.interval) {
|
||||||
await coll.insertOne({
|
await coll.insertOne({
|
||||||
...res.value, executeAfter: moment().add(...res.value.interval).toDate(),
|
...res.value, executeAfter: moment().add(...res.value.interval).toDate(),
|
||||||
|
|||||||
Reference in new issue
Block a user