mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30: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() {
|
export async function removeExpired() {
|
||||||
// Find all sessions that are containerId is not null and lastActivityAt is
|
// Find all sessions that are containerId is not null and lastActivityAt is
|
||||||
// less than the current time minus the expiry time
|
// less than the current time minus the expiry time
|
||||||
console.log('Checking for expired sessions')
|
try {
|
||||||
const sessions = await Session.find({
|
console.log('Checking for expired sessions')
|
||||||
containerId: { $ne: null },
|
const sessions = await Session.find({
|
||||||
lastActivityAt: { $lt: new Date(Date.now() - config.expiry) },
|
containerId: { $ne: null },
|
||||||
})
|
lastActivityAt: { $lt: new Date(Date.now() - config.containerExpiry) },
|
||||||
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()
|
|
||||||
})
|
})
|
||||||
)
|
await Promise.all(
|
||||||
console.log('Done checking for expired sessions')
|
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() {
|
export default function expiryRemovalScheduler() {
|
||||||
|
|||||||
Reference in new issue
Block a user