Skip to content

Commit

Permalink
feat: 新增排程刪除過期session
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Jan 30, 2021
1 parent a143d88 commit 1052b2a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ function Clear_Files()
}
}

const { MongoExe } = require('./models/common/data');
async function clearExpireSessions () {
let conn = await MongoExe();
let db = conn.db('My_ntunhs');
let collection = db.collection('sessions');

collection.deleteMany({"expires" : { $lte :new Date}} , async function (err , docs) {
console.log("delete expire sessions" , docs);
});
}

let scheduleDeleteExpireSession = schedule.scheduleJob({rule :'0 30 0 * * *'} , async function () {
await clearExpireSessions();
})
/*let scheduleUpdateCourse = schedule.scheduleJob({rule: '0 30 0 * * *'} ,function () {
console.log("update course");
updateCourseMain();
Expand Down

0 comments on commit 1052b2a

Please sign in to comment.