mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
wip: removing console log
This commit is contained in:
1 parent
515aefcadc
commit
82d1004ecf
16 files changed
+57
-34
No files matched your search
@@ -2,19 +2,19 @@ import schedule from 'node-schedule'
|
||||
import { Session } from '@linux-odyssey/models'
|
||||
import config from '../config.js'
|
||||
import { deleteContainer } from './docker.js'
|
||||
import logger from '../utils/logger.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
|
||||
try {
|
||||
console.log('Checking for expired sessions')
|
||||
const sessions = await Session.find({
|
||||
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)
|
||||
logger.info('Expiring session: ', session._id, session.containerId)
|
||||
try {
|
||||
await deleteContainer(session.containerId)
|
||||
} catch (err) {
|
||||
@@ -29,9 +29,8 @@ export async function removeExpired() {
|
||||
await session.save()
|
||||
})
|
||||
)
|
||||
console.log('Done checking for expired sessions')
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
logger.error(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user