mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
fix: update config field name
This commit is contained in:
1 parent
d745531a14
commit
59ced31094
1 file changed
+18
-14
@@ -6,21 +6,25 @@ import { deleteContainer } from './docker.js'
|
||||
export async function removeExpired() {
|
||||
// Find all sessions that are containerId is not null and lastActivityAt is
|
||||
// less than the current time minus the expiry time
|
||||
console.log('Checking for expired sessions')
|
||||
const sessions = await Session.find({
|
||||
containerId: { $ne: null },
|
||||
lastActivityAt: { $lt: new Date(Date.now() - config.expiry) },
|
||||
})
|
||||
await Promise.all(
|
||||
sessions.map(async (session) => {
|
||||
console.log('Expiring session: ', session._id, session.containerId)
|
||||
await deleteContainer(session.containerId)
|
||||
session.status = 'inactive'
|
||||
session.containerId = null
|
||||
await session.save()
|
||||
try {
|
||||
console.log('Checking for expired sessions')
|
||||
const sessions = await Session.find({
|
||||
containerId: { $ne: null },
|
||||
lastActivityAt: { $lt: new Date(Date.now() - config.containerExpiry) },
|
||||
})
|
||||
)
|
||||
console.log('Done checking for expired sessions')
|
||||
await Promise.all(
|
||||
sessions.map(async (session) => {
|
||||
console.log('Expiring session: ', session._id, session.containerId)
|
||||
await deleteContainer(session.containerId)
|
||||
session.status = 'inactive'
|
||||
session.containerId = null
|
||||
await session.save()
|
||||
})
|
||||
)
|
||||
console.log('Done checking for expired sessions')
|
||||
} catch (err) {
|
||||
console.error(err.message)
|
||||
}
|
||||
}
|
||||
|
||||
export default function expiryRemovalScheduler() {
|
||||
|
||||
Reference in new issue
Block a user