mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: connect terminal service to backend
feat: put terminal service into container refactor: separate main into terminal and websocket feat: create zsh using commander in home feat: pass backendUrl to container feat: pass token to ws server to cmd-hook feat: gen terminal access token for frontend feat: success to connect through traefik fix: handle invalid jwt feat: connect to session container via traefik
This commit is contained in:
1 parent
0b08a9a5d9
commit
5e81db2759
20 files changed
+281
-209
No files matched your search
@@ -1,7 +1,11 @@
|
||||
import { HydratedDocument } from 'mongoose'
|
||||
import { Session, UserProfile } from '../../../packages/models'
|
||||
import type { ISession, IUser } from '../../../packages/models'
|
||||
import { createContainer, deleteContainer } from '../containers/docker.js'
|
||||
import {
|
||||
createContainer,
|
||||
deleteContainer,
|
||||
getAndStartContainer,
|
||||
} from '../containers/docker.js'
|
||||
import logger from '../utils/logger.js'
|
||||
import { questManager } from './quest.js'
|
||||
|
||||
@@ -48,11 +52,10 @@ export async function createNewSession(
|
||||
throw new Error(`UserProfile ${userId} not found`)
|
||||
}
|
||||
|
||||
const container = await createContainer(
|
||||
`quest-${quest.id}-${userProfile.user.username}-${Date.now()}`,
|
||||
quest.id,
|
||||
quest.image
|
||||
)
|
||||
const containerName = `quest-${quest.id}-${userProfile.user.username}-${Date.now()}`
|
||||
|
||||
const container = await createContainer(containerName, quest.id, quest.image)
|
||||
await getAndStartContainer(container.id)
|
||||
|
||||
const newSession = new Session({
|
||||
user: userId,
|
||||
@@ -60,6 +63,9 @@ export async function createNewSession(
|
||||
containerId: container.id,
|
||||
})
|
||||
|
||||
console.log('container', container.id)
|
||||
console.log('containerName', `http://localhost/terminal/${containerName}`)
|
||||
|
||||
const progress = userProfile.progress.get(quest.id)
|
||||
if (!progress) {
|
||||
userProfile.progress.set(quest.id, {
|
||||
|
||||
Reference in new issue
Block a user