mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
fix: container removal, no secretKey panic
This commit is contained in:
1 parent
8e6227d9b4
commit
9abb7f15ba
4 files changed
+17
-11
No files matched your search
+1
-1
@@ -11,10 +11,10 @@
|
|||||||
"clean": "node src/cli/clean.js"
|
"clean": "node src/cli/clean.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@linux-odyssey/constants": "*",
|
||||||
"@linux-odyssey/file-graph": "*",
|
"@linux-odyssey/file-graph": "*",
|
||||||
"@linux-odyssey/models": "*",
|
"@linux-odyssey/models": "*",
|
||||||
"@linux-odyssey/utils": "*",
|
"@linux-odyssey/utils": "*",
|
||||||
"@linux-odyssey/constants": "*",
|
|
||||||
"bcrypt": "^5.1.1",
|
"bcrypt": "^5.1.1",
|
||||||
"commander": "^11.0.0",
|
"commander": "^11.0.0",
|
||||||
"connect-mongo": "^5.0.0",
|
"connect-mongo": "^5.0.0",
|
||||||
|
|||||||
@@ -22,12 +22,4 @@ const config = {
|
|||||||
|
|
||||||
config.baseUrl = get('BASE_URL', `http://${config.host}:${config.port}`)
|
config.baseUrl = get('BASE_URL', `http://${config.host}:${config.port}`)
|
||||||
|
|
||||||
if (!config.secret) {
|
|
||||||
console.warn(
|
|
||||||
'No SECRET_KEY found in .env! To set up a persistent key, please run the setup script:'
|
|
||||||
)
|
|
||||||
console.warn('yarn setup')
|
|
||||||
process.exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default config
|
export default config
|
||||||
@@ -15,7 +15,13 @@ export async function removeExpired() {
|
|||||||
await Promise.all(
|
await Promise.all(
|
||||||
sessions.map(async (session) => {
|
sessions.map(async (session) => {
|
||||||
console.log('Expiring session: ', session._id, session.containerId)
|
console.log('Expiring session: ', session._id, session.containerId)
|
||||||
await deleteContainer(session.containerId)
|
try {
|
||||||
|
await deleteContainer(session.containerId)
|
||||||
|
} catch (err) {
|
||||||
|
if (err.statusCode !== 404) {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}
|
||||||
if (session.status === 'active') {
|
if (session.status === 'active') {
|
||||||
session.status = 'inactive'
|
session.status = 'inactive'
|
||||||
}
|
}
|
||||||
@@ -25,7 +31,7 @@ export async function removeExpired() {
|
|||||||
)
|
)
|
||||||
console.log('Done checking for expired sessions')
|
console.log('Done checking for expired sessions')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err.message)
|
console.error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,14 @@ import sessionMiddleware from './middleware/session.js'
|
|||||||
import expiryRemovalScheduler from './containers/expiryChecker.js'
|
import expiryRemovalScheduler from './containers/expiryChecker.js'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
if (!config.secret) {
|
||||||
|
console.warn(
|
||||||
|
'No SECRET_KEY found in .env! To set up a persistent key, please run the setup script:'
|
||||||
|
)
|
||||||
|
console.warn('yarn setup')
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await connectDB(config.db)
|
await connectDB(config.db)
|
||||||
console.log('Connected to MongoDB')
|
console.log('Connected to MongoDB')
|
||||||
|
|||||||
Reference in new issue
Block a user